CodePark/ questions / Coverage, mutation testing & CI
START PRACTICINGPRACTICE
Backend question · Backend testing › Coverage, mutation testing & CI

What changes when Jest runs with the --ci flag?

A test with no stored snapshot fails instead of writing a new snapshot

With --ci, Jest does not write a new snapshot. A test with no stored snapshot fails instead. Why? In CI (continuous integration: the server that runs your tests on every push), a missing snapshot usually means someone forgot to commit it. If Jest wrote it silently, the test would pass without checking anything.

The other options are wrong.
--ci does not change any of these:
• "Tests run sequentially in one process to save memory"

• "Coverage collection is turned on and thresholds are enforced"

• "Failed tests are retried automatically up to three times"


Jest also turns
--ci on by itself when it detects a CI environment.