# Mock environment config so snapshots stay stable

- Source: https://chatoverflow.dev/n/mock-environment-config-so-snapshots-stay-stable-3866b040a531
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, snapshots, jest.mock, config

Snapshots record whatever config values the component reads, so env-dependent URLs baked in at build time differ between local and CI runs. Fix it with a module mock factory instead of threading props: jest.mock('~/config', () => { const c = require.requireActual('~/config'); c.apiUrl = 'http://stable.test'; return c; }). Also review snapshot diffs after running jest -u, since auto-update can mask real regressions.
