Skip to content

Commit

Permalink
chore: use wrap in a few more snapshots (#9800)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Apr 11, 2020
1 parent 9aeb70b commit 539f057
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 99 deletions.
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/coverageHandlebars.test.ts.snap
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`code coverage for Handlebars 1`] = `
"-----------|---------|----------|---------|---------|-------------------
-----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 75 | 66.67 | 66.67 | 66.67 |
greet.hbs | 75 | 66.67 | 66.67 | 66.67 | 10
-----------|---------|----------|---------|---------|-------------------"
-----------|---------|----------|---------|---------|-------------------
`;
16 changes: 8 additions & 8 deletions e2e/__tests__/__snapshots__/declarationErrors.test.ts.snap
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`warns if describe returns a Promise 1`] = `
" console.log
console.log
● Test suite failed to run
Returning a Promise from \\"describe\\" is not supported. Tests must be defined synchronously.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
Returning a Promise from "describe" is not supported. Tests must be defined synchronously.
Returning a value from "describe" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
Expand All @@ -17,15 +17,15 @@ exports[`warns if describe returns a Promise 1`] = `
at Object.describe (__tests__/describeReturnPromise.test.js:11:1)
"
`;

exports[`warns if describe returns something 1`] = `
" console.log
console.log
● Test suite failed to run
A \\"describe\\" callback must not return a value.
Returning a value from \\"describe\\" will fail the test in a future version of Jest.
A "describe" callback must not return a value.
Returning a value from "describe" will fail the test in a future version of Jest.
9 | 'use strict';
10 |
Expand All @@ -37,5 +37,5 @@ exports[`warns if describe returns something 1`] = `
at Object.describe (__tests__/describeReturnSomething.test.js:11:1)
"
`;
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/transform.test.ts.snap
Expand Up @@ -36,10 +36,10 @@ All files | 83.33 | 100 | 50 | 80 |
`;

exports[`transformer-config instruments only specific files and collects coverage 1`] = `
"------------|---------|----------|---------|---------|-------------------
------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------|---------|----------|---------|---------|-------------------
All files | 83.33 | 100 | 50 | 80 |
Covered.js | 83.33 | 100 | 50 | 80 | 13
------------|---------|----------|---------|---------|-------------------"
------------|---------|----------|---------|---------|-------------------
`;
3 changes: 2 additions & 1 deletion e2e/__tests__/coverageHandlebars.test.ts
Expand Up @@ -7,6 +7,7 @@

import {readFileSync} from 'fs';
import * as path from 'path';
import wrap from 'jest-snapshot-serializer-raw';
import {cleanup, run} from '../Utils';
import runJest from '../runJest';

Expand All @@ -22,7 +23,7 @@ it('code coverage for Handlebars', () => {
const result = runJest(dir, ['--coverage', '--no-cache']);

expect(result.exitCode).toBe(0);
expect(result.stdout).toMatchSnapshot();
expect(wrap(result.stdout)).toMatchSnapshot();

const coverageMapFile = path.join(coverageDir, 'coverage-final.json');
const coverageMap = JSON.parse(readFileSync(coverageMapFile, 'utf-8'));
Expand Down
9 changes: 6 additions & 3 deletions e2e/__tests__/declarationErrors.test.ts
Expand Up @@ -5,12 +5,15 @@
* LICENSE file in the root directory of this source tree.
*/

import wrap from 'jest-snapshot-serializer-raw';
import runJest from '../runJest';

const normalizeCircusJasmine = (str: string) =>
str
.replace(/console\.log .+:\d+/, 'console.log')
.replace(/.+addSpecsToSuite (.+:\d+:\d+).+\n/, '');
wrap(
str
.replace(/console\.log .+:\d+/, 'console.log')
.replace(/.+addSpecsToSuite (.+:\d+:\d+).+\n/g, ''),
);

it('warns if describe returns a Promise', () => {
const result = runJest('declaration-errors', [
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/transform.test.ts
Expand Up @@ -182,7 +182,7 @@ describe('transformer-config', () => {
expect(stdout).not.toMatch('NotCovered.js');
expect(stdout).not.toMatch('ExcludedFromCoverage.js');
// coverage result should not change
expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});
});

Expand Down
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`describe block _can_ have hooks if a child describe block has tests 1`] = `
"start_describe_definition: describe
start_describe_definition: describe
add_hook: afterEach
add_hook: beforeEach
add_hook: afterAll
Expand Down Expand Up @@ -36,11 +36,11 @@ run_describe_finish: describe
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;

exports[`describe block cannot have hooks and no tests 1`] = `
"start_describe_definition: describe
start_describe_definition: describe
add_hook: afterEach
add_hook: beforeEach
add_hook: afterAll
Expand All @@ -53,7 +53,7 @@ run_describe_finish: describe
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 4"
unhandledErrors: 4
`;

exports[`tests are not marked done until their parent afterAll runs 1`] = `
Expand Down
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`failures 1`] = `
"start_describe_definition: describe
start_describe_definition: describe
add_hook: beforeEach
add_hook: afterEach
add_test: one
Expand Down Expand Up @@ -30,11 +30,11 @@ run_describe_finish: describe
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;

exports[`simple test 1`] = `
"start_describe_definition: describe
start_describe_definition: describe
add_hook: beforeEach
add_hook: afterEach
add_test: one
Expand Down Expand Up @@ -63,5 +63,5 @@ run_describe_finish: describe
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`beforeAll is exectued correctly 1`] = `
"start_describe_definition: describe 1
start_describe_definition: describe 1
add_hook: beforeAll
add_test: test 1
start_describe_definition: 2nd level describe
Expand Down Expand Up @@ -40,11 +40,11 @@ run_describe_finish: describe 1
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;

exports[`beforeEach is executed before each test in current/child describe blocks 1`] = `
"start_describe_definition: describe
start_describe_definition: describe
add_hook: beforeEach
add_test: one
add_test: two
Expand Down Expand Up @@ -124,11 +124,11 @@ run_describe_finish: 2nd describe
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;

exports[`multiple before each hooks in one describe are executed in the right order 1`] = `
"start_describe_definition: describe 1
start_describe_definition: describe 1
add_hook: beforeEach
add_hook: beforeEach
start_describe_definition: 2nd level describe
Expand All @@ -154,5 +154,5 @@ run_describe_finish: describe 1
run_describe_finish: ROOT_DESCRIBE_BLOCK
run_finish
unhandledErrors: 0"
unhandledErrors: 0
`;
5 changes: 3 additions & 2 deletions packages/jest-circus/src/__tests__/afterAll.test.ts
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import wrap from 'jest-snapshot-serializer-raw';
import {runTest} from '../__mocks__/testUtils';

test('tests are not marked done until their parent afterAll runs', () => {
Expand Down Expand Up @@ -43,7 +44,7 @@ test('describe block cannot have hooks and no tests', () => {
})
`);

expect(result.stdout).toMatchSnapshot();
expect(wrap(result.stdout)).toMatchSnapshot();
});

test('describe block _can_ have hooks if a child describe block has tests', () => {
Expand All @@ -58,5 +59,5 @@ test('describe block _can_ have hooks if a child describe block has tests', () =
})
})
`);
expect(result.stdout).toMatchSnapshot();
expect(wrap(result.stdout)).toMatchSnapshot();
});
5 changes: 3 additions & 2 deletions packages/jest-circus/src/__tests__/baseTest.test.ts
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import wrap from 'jest-snapshot-serializer-raw';
import {runTest} from '../__mocks__/testUtils';

test('simple test', () => {
Expand All @@ -17,7 +18,7 @@ test('simple test', () => {
})
`);

expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});

test('failures', () => {
Expand All @@ -30,5 +31,5 @@ test('failures', () => {
})
`);

expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});
7 changes: 4 additions & 3 deletions packages/jest-circus/src/__tests__/hooks.test.ts
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import wrap from 'jest-snapshot-serializer-raw';
import {runTest} from '../__mocks__/testUtils';

test('beforeEach is executed before each test in current/child describe blocks', () => {
Expand Down Expand Up @@ -33,7 +34,7 @@ test('beforeEach is executed before each test in current/child describe blocks',
})
`);

expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});

test('multiple before each hooks in one describe are executed in the right order', () => {
Expand All @@ -52,7 +53,7 @@ test('multiple before each hooks in one describe are executed in the right order
});
`);

expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});

test('beforeAll is exectued correctly', () => {
Expand All @@ -69,5 +70,5 @@ test('beforeAll is exectued correctly', () => {
});
`);

expect(stdout).toMatchSnapshot();
expect(wrap(stdout)).toMatchSnapshot();
});
@@ -1,83 +1,83 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Watch mode flows Pressing "P" enters pattern mode 1`] = `
"
pattern › p
[MOCK - cursorSavePosition]
[MOCK - cursorTo(12, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 2`] = `
"
pattern › p.
[MOCK - cursorSavePosition]
[MOCK - cursorTo(13, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 3`] = `
"
pattern › p.*
[MOCK - cursorSavePosition]
[MOCK - cursorTo(14, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 4`] = `
"
pattern › p.*1
[MOCK - cursorSavePosition]
[MOCK - cursorTo(15, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 5`] = `
"
pattern › p.*10
[MOCK - cursorSavePosition]
[MOCK - cursorTo(16, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 6`] = `
"
pattern › p.*1
[MOCK - cursorSavePosition]
[MOCK - cursorTo(15, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 7`] = `
"
pattern › p.*
[MOCK - cursorSavePosition]
[MOCK - cursorTo(14, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 8`] = `
"
pattern › p.*3
[MOCK - cursorSavePosition]
[MOCK - cursorTo(15, 5)]
[MOCK - cursorRestorePosition]"
[MOCK - cursorRestorePosition]
`;

exports[`Watch mode flows Pressing "P" enters pattern mode 9`] = `
Expand Down

0 comments on commit 539f057

Please sign in to comment.