diff --git a/CHANGELOG.md b/CHANGELOG.md index 33376b8ff8a6..eb0fcbd1f688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ `assert`, `count`, `countReset`, `dir`, `dirxml`, `group`, `groupCollapsed`, `groupEnd`, `time`, `timeEnd` ([#5514](https://github.com/facebook/jest/pull/5514)) +* `[docs]` Add documentation for interactive snapshot mode ([#5291](https://github.com/facebook/jest/pull/5291)) ## jest 22.2.2 @@ -143,6 +144,7 @@ * `[jest-cli]` Make Jest exit without an error when no tests are found in the case of `--lastCommit`, `--findRelatedTests`, or `--onlyChanged` options having been passed to the CLI +* `[jest-cli]` Add interactive snapshot mode ([#3831](https://github.com/facebook/jest/pull/3831)) ### Fixes @@ -171,9 +173,6 @@ ([#5279](https://github.com/facebook/jest/pull/5279)) * `[jest-config]` Fix breaking change in `--testPathPattern` ([#5269](https://github.com/facebook/jest/pull/5269)) - -### Fixes - * `[docs]` Document caveat with mocks, Enzyme, snapshots and React 16 ([#5258](https://github.com/facebook/jest/issues/5258)) diff --git a/docs/SnapshotTesting.md b/docs/SnapshotTesting.md index 287274c71573..becaf27ebe59 100644 --- a/docs/SnapshotTesting.md +++ b/docs/SnapshotTesting.md @@ -121,6 +121,20 @@ You can try out this functionality by cloning the [snapshot example](https://github.com/facebook/jest/tree/master/examples/snapshot), modifying the `Link` component, and running Jest. +### Interactive Snapshot Mode + +Failed snapshots can also be updated interactively in watch mode: + +![](/jest/img/content/interactiveSnapshot.png) + +Once you enter Interactive Snapshot Mode, Jest will step you through +the failed snapshots one test suite at a time and give you the opportunity to +review the failed output. + +From here you can choose to update that snapshot or skip to the next: + +![](/jest/img/content/interactiveSnapshotUpdate.gif) + ### Tests Should Be Deterministic Your tests should be deterministic. That is, running the same tests multiple diff --git a/packages/jest-cli/src/__tests__/__snapshots__/snapshot_interactive_mode.test.js.snap b/packages/jest-cli/src/__tests__/__snapshots__/snapshot_interactive_mode.test.js.snap index 9b8e2e9a04fb..fd47bf1ef31f 100644 --- a/packages/jest-cli/src/__tests__/__snapshots__/snapshot_interactive_mode.test.js.snap +++ b/packages/jest-cli/src/__tests__/__snapshots__/snapshot_interactive_mode.test.js.snap @@ -12,7 +12,7 @@ exports[`SnapshotInteractiveMode updateWithResults overlay handle progress UI 1` Watch Usage › Press u to update failing snapshots for this test. - › Press s to skip the current snapshot. + › Press s to skip the current test suite. › Press q to quit Interactive Snapshot Update Mode. › Press Enter to trigger a test run. " diff --git a/packages/jest-cli/src/snapshot_interactive_mode.js b/packages/jest-cli/src/snapshot_interactive_mode.js index ce97d15cbafa..fdd6f62121fc 100644 --- a/packages/jest-cli/src/snapshot_interactive_mode.js +++ b/packages/jest-cli/src/snapshot_interactive_mode.js @@ -54,7 +54,7 @@ export default class SnapshotInteractiveMode { this._testFilePaths.length > 1 ? chalk.dim(' \u203A Press ') + 's' + - chalk.dim(' to skip the current snapshot.') + chalk.dim(' to skip the current test suite.') : '', chalk.dim(' \u203A Press ') + diff --git a/website/static/img/content/interactiveSnapshot.png b/website/static/img/content/interactiveSnapshot.png new file mode 100644 index 000000000000..0d42f67c4c8c Binary files /dev/null and b/website/static/img/content/interactiveSnapshot.png differ diff --git a/website/static/img/content/interactiveSnapshotUpdate.gif b/website/static/img/content/interactiveSnapshotUpdate.gif new file mode 100644 index 000000000000..83928f705ca6 Binary files /dev/null and b/website/static/img/content/interactiveSnapshotUpdate.gif differ