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

Fix testNamePattern value with interactive snapshots #6579

Merged
merged 3 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- `[jest-snapshot]` Introduce `toMatchInlineSnapshot` and `toThrowErrorMatchingInlineSnapshot` matchers ([#6380](https://github.com/facebook/jest/pull/6380))

### Fixes

- `[jest-cli]` Fix `testNamePattern` value with interactive snapshots ([#6579](https://github.com/facebook/jest/pull/6579))

### Chore & Maintenance

- `[website]` Switch domain to https://jestjs.io ([#6549](https://github.com/facebook/jest/pull/6549))
Expand Down
36 changes: 18 additions & 18 deletions packages/jest-cli/src/__tests__/snapshot_interactive_mode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to run process the first file', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -53,8 +53,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to abort', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -66,8 +66,8 @@ describe('SnapshotInteractiveMode', () => {

test('call to reset', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'second.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'second.js'},
];
instance.run(assertions, mockCallback);
expect(instance.isActive()).toBeTruthy();
Expand All @@ -85,15 +85,15 @@ describe('SnapshotInteractiveMode', () => {
});

test('press ENTER trigger a run', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];
instance.run(assertions, mockCallback);
instance.put(KEYS.ENTER);
expect(mockCallback).toHaveBeenCalledTimes(2);
expect(mockCallback).toHaveBeenCalledWith(assertions[0], false);
});

test('skip 1 test, then restart', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand All @@ -113,7 +113,7 @@ describe('SnapshotInteractiveMode', () => {
});

test('skip 1 test, then quit', () => {
const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('SnapshotInteractiveMode', () => {
instance.updateWithResults({snapshot: {failure: true}});
});

const assertions = [{path: 'first.js', title: 'test one'}];
const assertions = [{fullName: 'test one', path: 'first.js'}];

instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand All @@ -162,8 +162,8 @@ describe('SnapshotInteractiveMode', () => {

test('skip 2 tests, then finish and restart', () => {
const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];
instance.run(assertions, mockCallback);
expect(mockCallback).nthCalledWith(1, assertions[0], false);
Expand Down Expand Up @@ -207,8 +207,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down Expand Up @@ -255,8 +255,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down Expand Up @@ -303,8 +303,8 @@ describe('SnapshotInteractiveMode', () => {
});

const assertions = [
{path: 'first.js', title: 'test one'},
{path: 'first.js', title: 'test two'},
{fullName: 'test one', path: 'first.js'},
{fullName: 'test two', path: 'first.js'},
];

instance.run(assertions, mockCallback);
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/plugins/update_snapshots_interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin {
testResult.testResults.forEach(result => {
if (result.status === 'failed') {
failedTestPaths.push({
fullName: result.fullName,
path: testResult.testFilePath,
title: result.title,
});
}
});
Expand Down Expand Up @@ -77,7 +77,7 @@ class UpdateSnapshotInteractivePlugin extends BaseWatchPlugin {
(assertion: ?AssertionLocation, shouldUpdateSnapshot: boolean) => {
updateConfigAndRun({
mode: 'watch',
testNamePattern: assertion ? `^${assertion.title}$` : '',
testNamePattern: assertion ? `^${assertion.fullName}$` : '',
testPathPattern: assertion ? assertion.path : '',

updateSnapshot: shouldUpdateSnapshot ? 'all' : 'none',
Expand Down
2 changes: 1 addition & 1 deletion types/TestResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export type FailedAssertion = {|
|};

export type AssertionLocation = {|
fullName: string,
path: string,
title: string,
|};

export type Status = 'passed' | 'failed' | 'skipped' | 'pending';
Expand Down