Lesson 2 / الدرس 2
What not to automate / ما لا يُؤتمت
Every automated test costs something forever: it has to be written, run, and repaired every time the product changes. Deciding what to leave alone is the part of automation that most teams skip, and it is why their suites collapse in year two.
كل اختبار آلي يكلّف شيئًا إلى الأبد: فلا بد أن يُكتب ويُجرى ويُصلَح كلما تغيّر المنتج. واختيار ما يُترك هو الجزء الذي تتخطاه معظم الفرق من الأتمتة، وهو سبب انهيار مجموعاتها في السنة الثانية.
An automated test is not free once it is written. It runs on every build, so it costs minutes; it breaks whenever the thing it touches changes, so it costs repairs; and every repair is a chance to weaken it until it passes again. A suite is a garden, not a warehouse. Teams that automate everything they can end up maintaining a suite instead of testing a product.
Leave these to a person
| Do not automate | Because |
|---|---|
| Does it look right | A machine compares pixels; it cannot tell ugly from unusual |
| Is this wording clear | Clarity is a judgement about a reader, and there is no assertion for it |
| A feature still being designed | It will change five times; you will repair the test five times |
| Something run once, ever | Writing it costs more than running it by hand |
| A test nobody can make fail | If you cannot break it deliberately, it is checking nothing |
| Exploratory work | It is designed while it runs, which is the one thing a script cannot do |
None of these are "too hard to automate". They are things where automating removes the judgement that was doing the work.
The question to ask
Before automating anything, ask: how many times will this run before the thing it tests changes? A sign-in flow that has been stable for two years will run a thousand times — automate it. A checkout being redesigned this quarter will run twelve times and be rewritten — test it by hand and automate it when it settles. The answer is not about importance; it is about stability.
// Automate: stable, high value, runs on every build.
test('a signed-out visitor cannot open the dashboard', async ({ page }) => {
await page.goto('/dashboard');
await expect(page).toHaveURL(/sign-in/);
});
// Do NOT automate: this is a judgement, and the assertion is a lie.
test('the dashboard looks professional', async ({ page }) => {
await page.goto('/dashboard');
await expect(page.locator('.card')).toHaveCount(4); // ...that is not what was asked
});
Check yourself / اختبر نفسك
1. Which question best decides whether to automate a test?
Importance argues for testing it, not for automating it. Automation pays off through repetition, so the deciding factor is stability: a test that will be rewritten next month never earns back what it cost.
2. A test called "the dashboard looks professional" asserts there are four cards. What is wrong?
The question was about appearance; the assertion is about arithmetic. It will stay green through any visual disaster that keeps four cards, and go red the day someone deliberately adds a fifth — wrong in both directions.
3. An automated test has failed three times running, each time because the product legitimately changed. What should you do?
A test that only ever fails for legitimate reasons has stopped carrying information; each repair is pure cost. Deleting it is a maintenance decision, not an admission that testing failed.
Score / النتيجة: 0 / 3