diff --git a/packages/jest-cli/src/__tests__/watch.test.js b/packages/jest-cli/src/__tests__/watch.test.js index c37ec65251b3..56e4aea3bce7 100644 --- a/packages/jest-cli/src/__tests__/watch.test.js +++ b/packages/jest-cli/src/__tests__/watch.test.js @@ -257,6 +257,8 @@ describe('Watch mode flows', () => { }); it('Pressing "u" reruns the tests in "update snapshot" mode', () => { + globalConfig.updateSnapshot = 'new'; + watch(globalConfig, contexts, pipe, hasteMapInstances, stdin); runJestMock.mockReset(); @@ -270,7 +272,7 @@ describe('Watch mode flows', () => { stdin.emit(KEYS.A); // updateSnapshot is not sticky after a run. expect(runJestMock.mock.calls[1][0].globalConfig).toMatchObject({ - updateSnapshot: 'none', + updateSnapshot: 'new', watch: false, }); }); diff --git a/packages/jest-cli/src/watch.js b/packages/jest-cli/src/watch.js index 0666084c36c1..6bdb1de7a1d3 100644 --- a/packages/jest-cli/src/watch.js +++ b/packages/jest-cli/src/watch.js @@ -228,13 +228,15 @@ export default function watch( startRun(globalConfig); break; case KEYS.U: + const previousUpdateSnapshot = globalConfig.updateSnapshot; + globalConfig = updateGlobalConfig(globalConfig, { updateSnapshot: 'all', }); startRun(globalConfig); globalConfig = updateGlobalConfig(globalConfig, { // updateSnapshot is not sticky after a run. - updateSnapshot: 'none', + updateSnapshot: previousUpdateSnapshot, }); break; case KEYS.I: