Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive Snapshot Update mode #3831

Merged
merged 14 commits into from
Jan 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes after rebase
  • Loading branch information
genintho committed Dec 19, 2017
commit f8d4c38a680355580978b50bc7462d6d2a5cbb07
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -28,6 +28,5 @@ npm-debug.log
npm-debug.log*
yarn-error.log*


# JetBrains IDE
.idea/*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a part of your global gitignore, but I'm not against leaving this here

Original file line number Diff line number Diff line change
@@ -9,14 +9,14 @@ exports[`SnapshotInteractiveMode updateWithResults overlay handle progress UI 1`
[MOCK - cursorUp]
[MOCK - eraseDown]

<bold>Interactive Snapshot Progress
› <bold><red>2 suites failed</>, <bold><green>1 suite passed</>

<bold>Watch Usage
<dim> › Press u<dim> to update failing snapshots for this test.
<dim> › Press s<dim> to skip the current snapshot.
<dim> › Press q<dim> to quit Interactive Snapshot Update Mode.
<dim> › Press Enter<dim> to trigger a test run.
<bold>Interactive Snapshot Progress</>
› <bold><red>2 suites failed</></>, <bold><green>1 suite passed</></>

<bold>Watch Usage</>
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
<dim> › Press </>s<dim> to skip the current snapshot.</>
<dim> › Press </>q<dim> to quit Interactive Snapshot Update Mode.</>
<dim> › Press </>Enter<dim> to trigger a test run.</>
"
`;

@@ -27,13 +27,13 @@ exports[`SnapshotInteractiveMode updateWithResults with a test failure simply up
[MOCK - cursorUp]
[MOCK - eraseDown]

<bold>Interactive Snapshot Progress
› <bold><red>1 suite failed</>
<bold>Interactive Snapshot Progress</>
› <bold><red>1 suite failed</></>

<bold>Watch Usage
<dim> › Press u<dim> to update failing snapshots for this test.
<dim> › Press q<dim> to quit Interactive Snapshot Update Mode.
<dim> › Press Enter<dim> to trigger a test run.
<bold>Watch Usage</>
<dim> › Press </>u<dim> to update failing snapshots for this test.</>
<dim> › Press </>q<dim> to quit Interactive Snapshot Update Mode.</>
<dim> › Press </>Enter<dim> to trigger a test run.</>
"
`;

12 changes: 2 additions & 10 deletions packages/jest-cli/src/snapshot_interactive_mode.js
Original file line number Diff line number Diff line change
@@ -13,10 +13,9 @@ import type {AggregatedResult} from 'types/TestResult';
const chalk = require('chalk');
const ansiEscapes = require('ansi-escapes');
const {pluralize} = require('./reporters/utils');
const {rightPad} = require('./lib/terminal_utils');
const {KEYS} = require('./constants');

module.exports = class SnapshotInteractiveMode {
export default class SnapshotInteractiveMode {
_pipe: stream$Writable | tty$WriteStream;
_isActive: boolean;
_updateTestRunnerConfig: (path: string, shouldUpdateSnapshot: boolean) => *;
@@ -36,13 +35,6 @@ module.exports = class SnapshotInteractiveMode {
this._pipe.write(ansiEscapes.scrollDown);
this._pipe.write(ansiEscapes.scrollDown);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why do we have to scroll down? Removing these 2 lines leaves the functionality unchanged on iTerm and macOS Terminal.


// this._pipe.write(ansiEscapes.cursorSavePosition);
// this._pipe.write(ansiEscapes.cursorTo(0, 0));
//
// const title = rightPad(' -> Interactive Snapshot Update Activated <-');
// this._pipe.write(chalk.black.bold.bgYellow(title));
//
// this._pipe.write(ansiEscapes.cursorRestorePosition);
this._pipe.write(ansiEscapes.cursorUp(6));
this._pipe.write(ansiEscapes.eraseDown);

@@ -141,4 +133,4 @@ module.exports = class SnapshotInteractiveMode {
this._isActive = true;
this._run(false);
}
};
}
3 changes: 1 addition & 2 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
@@ -15,10 +15,9 @@ import ansiEscapes from 'ansi-escapes';
import chalk from 'chalk';
import getChangedFilesPromise from './get_changed_files_promise';
import {replacePathSepForRegex} from 'jest-regex-util';
import {getFailedSnapshotTests} from 'jest-util';
import HasteMap from 'jest-haste-map';
import isValidPath from './lib/is_valid_path';
import {isInteractive} from 'jest-util';
import {getFailedSnapshotTests, isInteractive} from 'jest-util';
import {print as preRunMessagePrint} from './pre_run_message';
import createContext from './lib/create_context';
import runJest from './run_jest';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const getFailedSnapshotTests = require('../get_failed_snapshot_tests');
import getFailedSnapshotTests from '../get_failed_snapshot_tests';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a license not with @flow pragma


test('return a list of path', () => {
const targetFilename = 'somewhere.js';
2 changes: 1 addition & 1 deletion packages/jest-util/src/get_failed_snapshot_tests.js
Original file line number Diff line number Diff line change
@@ -19,4 +19,4 @@ function getFailedSnapshotTests(testResults: AggregatedResult) {
return failedTestPaths;
}

module.exports = getFailedSnapshotTests;
export default getFailedSnapshotTests;
2 changes: 1 addition & 1 deletion packages/jest-util/src/index.js
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ module.exports = {
clearLine,
createDirectory,
formatTestResults,
getFailedSnapshotTests,
getConsoleOutput,
getFailedSnapshotTests,
installCommonGlobals,
isInteractive,
setGlobal,