Lesson 15 / الدرس 15
Running without you / الإجراء من غيرك
A test suite that only runs when someone remembers is barely a suite. Continuous integration is a machine that runs it on every change, and the value is entirely in how fast it tells somebody, and whether they believe it.
مجموعة اختبارات لا تجري إلا حين يتذكر أحد بالكاد تكون مجموعة. والتكامل المستمر آلة تجريها عند كل تغيير، وقيمتها كلها في سرعة إخبارها أحدًا، وفي هل يصدّقونها.
Continuous integration is a server that watches the repository and, whenever anyone pushes, checks out the code, installs what it needs, starts the application and runs your tests. Nothing about it is conceptually clever — it is the same commands you run locally, on a machine that never forgets and never decides it is probably fine.
What changes when a machine runs it
-
No browser window. Tests run headless, so anything that depended on you watching — a manual login, a file you had open — fails. لا نافذة متصفح. فالاختبارات تجري بلا رأس، فيرسب كل ما اعتمد على مشاهدتك — دخول يدوي، أو ملف كان مفتوحًا عندك.
-
A clean machine, every time. No cached login, no leftover test data, no browser extension. This is a feature: it is the only environment that resembles a new user. جهاز نظيف في كل مرة. بلا دخول مخزّن، ولا بيانات اختبار متبقية، ولا إضافة متصفح. وهذه ميزة: فهي البيئة الوحيدة التي تشبه مستخدمًا جديدًا.
-
Different speed. Usually slower and more variable, which is where every fixed
waitForTimeoutyou wrote comes back to find you.سرعة مختلفة. أبطأ وأكثر تقلبًا عادةً، وهنا يعود كلwaitForTimeoutثابت كتبته ليجدك. -
Nobody is watching. The output is all anyone will see, so the screenshot, video and trace the runner saves are the whole of your evidence. لا أحد يشاهد. فالمخرجات هي كل ما سيراه أحد، ولقطة الشاشة والفيديو والأثر التي يحفظها المشغّل هي دليلك كله.
# .github/workflows/test.yml — the whole idea, in one file
name: tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npm run test
# Without this, a failure in CI is a sentence with no evidence behind it.
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
Fast enough to be read
A suite that takes forty minutes gets ignored, because nobody waits forty minutes to know whether their change was fine. Split it: the fast, broad checks — units, API tests, a handful of smoke journeys — on every push, and the long browser suite nightly or before a release. Feedback that arrives after the developer has moved on is feedback that costs more than it saves.
Check yourself / اختبر نفسك
1. Why upload screenshots and traces only on failure?
Nobody watched the run, so the artefacts are the entire record of what happened. They matter enormously when it is red and not at all when it is green, which is exactly what the condition expresses.
2. A full browser suite takes forty minutes. What is the usual answer?
Feedback that arrives after the developer has moved on costs more than it saves, so the fast layer has to run on every push. The slow layer still has value; it just does not have to block a push.
3. What happens once a team routinely merges with a red build?
A signal that is routinely overridden is not a signal. The dangerous part is not the ignored test — it is that the team keeps the confidence a working suite would have given them, without the suite.
Score / النتيجة: 0 / 3