Diagnose a Test That Passes Locally but Fails in CI
Scenario
Your tests passed on your laptop, then failed on GitHub Actions. Compare three common CI log messages.
Try it yourself
Match each CI failure log to its real cause.
| Case | Result |
|---|---|
| Error: ENOENT: no such file or directory, open "fixtures/booking.json" | Select a choice above to see what happens. |
| sh: 1: vite: not found | Select a choice above to see what happens. |
| Error: BOOKING_API_KEY is undefined during page load | Select a choice above to see what happens. |
Reveal the explanation
- Error: ENOENT: no such file or directory, open "fixtures/booking.json"
Untracked file. The fixture exists on your laptop but was never `git add`ed and committed.
- sh: 1: vite: not found
Missing install step. CI ran `npm run build` before running `npm ci` or `npm install`.
- Error: BOOKING_API_KEY is undefined during page load
Hidden runtime secret dependency. Static apps must bundle checked-in data without requiring runtime API keys.
A CI-only failure is usually a gift: it catches missing commits, missing install commands, or undeclared environment assumptions before another teammate hits them.
Your turn
Write a 2-step checklist to reproduce a clean CI build locally before pushing.
Common mistake Re-running tests with old `node_modules` and untracked local files still sitting in the folder.
Check your work
Check `git status` for untracked fixtures/files, then run clean install (`npm ci` / `npm install`) + `npm test` + `npm run build`.
Quick check
This browser could not save your progress. Changes last until you leave the page.