Curriculum

Curriculum

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.

Selected choicePick a choice below
Result—

Try it yourself

Match each CI failure log to its real cause.

Reveal the explanation
  1. 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.

  2. sh: 1: vite: not found

    Missing install step. CI ran `npm run build` before running `npm ci` or `npm install`.

  3. 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.

Review first

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

Tests pass on your machine, but CI logs `ENOENT: fixtures/booking.json`. What should you check first?
Show the answer and reasoning

Correct answer Whether fixtures/booking.json is committed in git and has matching path casing

CI only sees committed files and uses case-sensitive Linux paths.