Skip to content

Commit

Permalink
Fix updateSnapshot resetting after updating snapshots in watch mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbujok authored and cpojer committed Jan 15, 2018
1 parent afc0a49 commit 634e474
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/jest-cli/src/__tests__/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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,
});
});
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 634e474

Please sign in to comment.