An AI tool hands you a test. It has a clear title, tidy locators and no obvious mistake. A locator is the part of a test that finds an element on the page. A teammate asks if it is ready to merge, which means ready to add to the team's code. "It looks fine" is not an answer a senior reviewer accepts.
You need a fixed list to go through, so you look at the same things every time. This lecture gives you six checks. They are the same six steps as our short guide, Check an AI draft before you use it.
We will walk through them on one real reply.
The reply
We sent this request about a sign-in page. Notice what it does not contain: a written requirement.
Write a Playwright test in TypeScript for the sign-in page at https://www.testacademy.dev/playground/auth
I do not have a written requirement. This is the code that handles the form:
const VALID_EMAIL = "demo@nimbus.app";
const VALID_PASSWORD = "secure123";
if (email.toLowerCase() === VALID_EMAIL && password === VALID_PASSWORD) {
onSuccess("Alex");
} else {
setAuthError("Invalid email or password.");
}
The form has an Email field, a Password field and a "Sign in" button. Test what happens with a wrong password.
This reply is one of the fifteen test files described in lecture 1, under "How these tests were collected".
The reply was one short test. It opens the page, types the valid email and a wrong password, and clicks Sign in. Then it expects the error text from the code we pasted.
We do not print the test here. It is close to the answer of a graded exercise.
Check 1: the framework and its binding
A binding is the library for your programming language. Playwright has bindings for TypeScript, Python, Java and C#, and their code looks different.
We asked for Playwright in TypeScript and got it. Do this check first. A test in the wrong binding cannot run in your project at all.
Check 2: the setup data and the control
Check that the test uses the right data and reaches the right control. A control is something the user acts on, such as a field or a button.
The email is the one from our request. The password is wrong on purpose. The fields are found by their labels, "Email" and "Password", and the button by its name. All three matched the real page when we ran it.
Check 3: the assertion against the approved rule
An assertion is the check that can fail. Read it, then compare it with the rule someone approved.
Here there is no approved rule. Our request said so, and the reply said so too:
"Since there is no written requirement, the expected behavior is derived from the provided implementation."
The expected text was copied from the app's code. So the test checks that the code does what the code says. If the message in the code is the wrong message, this test agrees with it. This is the one check the reply fails, and lecture 6 is about it.
Check 4: waits, skipped steps, repeats and cleanup
Look for anything that can hide a failure:
- a fixed wait, which pauses for a set time instead of waiting for the page;
- a step marked to be skipped;
- a loop that tries again until it passes;
- cleanup that removes the evidence of a failure.
This reply has none of them.
Check 5: run it on the working app and on a broken copy
The reply ended with this: "The test assumes the fields have accessible labels and has not been executed against the live page." An accessible label is the text that names a field, such as "Email". So nobody had run it yet.
We ran it on the working app. It passed.
Then we ran it on two copies with a bug added on purpose. In one, a wrong password shows no error message. In the other, any password is accepted. The test failed on both, which is what you want.
Count the bug as caught when the test fails because of that bug. So when a test fails, read the failing step. It tells you whether the test found the bug or only lost a locator.
Check 6: after an edit, repeat both runs
This reply needed no edit. Many do. Another reply in this course used a button name that was not on the page. We corrected the name. Then we ran the test on the working app and the broken copies.
That second pair of runs matters. An edit can make the test pass on the working app and also stop it catching the bug. Accept a repair when the working run passes and the broken copy still makes it fail. If you could only run the working app, write that limit down in the pull request.
What the six checks showed
Checks 1, 2, 4 and 5 passed. Check 3 failed. Check 6 did not apply, because we made no edit.
Look at which kind of check found the problem. Check 5 is a run, and it gave the right results. The problem was in check 3, and you find that one by reading. No run can show that an expected value came from the wrong place, because the app and the test agree.
A reviewer could write this in the pull request: "The test catches both planted bugs. Its expected message is copied from the code. Please link the rule that approves this wording."
It works the other way too. Lecture 1 showed two tests that read well and missed a bug. Only a run found that. You need both kinds of check, every time.
Your exercise. A sign-in test expects the dashboard after a wrong password. The exercise states the rule: a wrong password is rejected and an error message is shown. The rule does not give the wording of the message. So assert that the error message is shown, and do not copy its wording from the page or from the code.
Remember this:
- Check the framework and binding, the data and control, the assertion against the rule, and anything that can hide a failure.
- Then run the test on the working app and on a broken copy, and run both again after any edit.
- Reading finds problems a run cannot find. A run finds problems reading cannot find.
- A test can catch planted bugs and still take its expected value from the wrong place.
Reference: Best practices.