Skip to content

Commit

Permalink
chore: run dedent over all e2e test content (#9525)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 6, 2020
1 parent 2ac4224 commit 2bc336b
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 70 deletions.
4 changes: 2 additions & 2 deletions e2e/Utils.ts
Expand Up @@ -3,7 +3,6 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/

import * as fs from 'fs';
Expand All @@ -14,6 +13,7 @@ import {Config} from '@jest/types';
import {ExecaReturnValue, sync as spawnSync} from 'execa';
import {createDirectory} from 'jest-util';
import rimraf = require('rimraf');
import dedent = require('dedent');

interface RunResult extends ExecaReturnValue {
status: number;
Expand Down Expand Up @@ -85,7 +85,7 @@ export const writeFiles = (
}
fs.writeFileSync(
path.resolve(directory, ...fileOrPath.split('/')),
files[fileOrPath],
dedent(files[fileOrPath]),
);
});
};
Expand Down
Expand Up @@ -17,7 +17,7 @@ Ran all test suites.
`;
exports[`prints console.logs when run with forceExit 3`] = `
console.log __tests__/a-banana.js:2
console.log __tests__/a-banana.js:1
Hey
`;
6 changes: 3 additions & 3 deletions e2e/__tests__/__snapshots__/coverageThreshold.test.ts.snap
Expand Up @@ -20,7 +20,7 @@ exports[`excludes tests matched by path threshold groups from global group: stdo
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 50 | 100 | 50 | 50 |
apple.js | 0 | 100 | 0 | 0 | 2,3
apple.js | 0 | 100 | 0 | 0 | 1,2
banana.js | 100 | 100 | 100 | 100 |
-----------|---------|----------|---------|---------|-------------------
`;
Expand Down Expand Up @@ -54,7 +54,7 @@ exports[`exits with 1 if coverage threshold is not met: stdout 1`] = `
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------|---------|----------|---------|---------|-------------------
All files | 50 | 100 | 0 | 50 |
not-covered.js | 50 | 100 | 0 | 50 | 3
not-covered.js | 50 | 100 | 0 | 50 | 2
----------------|---------|----------|---------|---------|-------------------
`;
Expand Down Expand Up @@ -104,6 +104,6 @@ exports[`file is matched by all path and glob threshold groups: stdout 1`] = `
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files | 50 | 100 | 0 | 50 |
banana.js | 50 | 100 | 0 | 50 | 3
banana.js | 50 | 100 | 0 | 50 | 2
-----------|---------|----------|---------|---------|-------------------
`;
24 changes: 10 additions & 14 deletions e2e/__tests__/__snapshots__/globals.test.ts.snap
Expand Up @@ -31,14 +31,12 @@ FAIL __tests__/onlyConstructs.test.js
Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
1 |
2 | it('it', () => {});
> 3 | it('it, no implementation');
| ^
4 | test('test, no implementation');
5 |
1 | it('it', () => {});
> 2 | it('it, no implementation');
| ^
3 | test('test, no implementation');
at Object.it (__tests__/onlyConstructs.test.js:3:5)
at Object.it (__tests__/onlyConstructs.test.js:2:1)
`;
exports[`cannot test with no implementation 2`] = `
Expand All @@ -55,14 +53,12 @@ FAIL __tests__/onlyConstructs.test.js
Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder.
1 |
2 | it('it', () => {});
> 3 | it('it, no implementation');
| ^
4 | test('test, no implementation');
5 |
1 | it('it', () => {});
> 2 | it('it, no implementation');
| ^
3 | test('test, no implementation');
at Object.it (__tests__/onlyConstructs.test.js:3:5)
at Object.it (__tests__/onlyConstructs.test.js:2:1)
`;
exports[`cannot test with no implementation with expand arg 2`] = `
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/jest.config.js.test.ts.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`traverses directory tree up until it finds jest.config 1`] = `
console.log ../../../__tests__/a-banana.js:4
console.log ../../../__tests__/a-banana.js:3
<<REPLACED>>/jest.config.js/some/nested/directory
`;
Expand Down
34 changes: 15 additions & 19 deletions e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.ts.snap
Expand Up @@ -12,12 +12,11 @@ test('inline snapshots', () =>

exports[`basic support: snapshot mismatch 1`] = `
test('inline snapshots', () =>
expect({apple: 'updated value'}).toMatchInlineSnapshot(\`
Object {
"apple": "original value",
}
\`));
expect({apple: 'updated value'}).toMatchInlineSnapshot(\`
Object {
"apple": "original value",
}
\`));
`;

exports[`basic support: snapshot passed 1`] = `
Expand Down Expand Up @@ -80,16 +79,15 @@ test('handles property matchers', () => {
exports[`handles property matchers: snapshot failed 1`] = `
test('handles property matchers', () => {
expect({createdAt: "string"}).toMatchInlineSnapshot(
{createdAt: expect.any(Date)},
\`
Object {
"createdAt": Any<Date>,
}
expect({createdAt: "string"}).toMatchInlineSnapshot(
{createdAt: expect.any(Date)},
\`
);
Object {
"createdAt": Any<Date>,
}
\`
);
});
`;
exports[`handles property matchers: snapshot passed 1`] = `
Expand Down Expand Up @@ -163,11 +161,9 @@ test('removes obsolete external snapshots', () => {
`;
exports[`removes obsolete external snapshots: initial write 1`] = `
test('removes obsolete external snapshots', () => {
expect('1').toMatchSnapshot();
});
test('removes obsolete external snapshots', () => {
expect('1').toMatchSnapshot();
});
`;
exports[`removes obsolete external snapshots: inline snapshot written 1`] = `
Expand Down
16 changes: 6 additions & 10 deletions e2e/__tests__/__snapshots__/watchModeOnlyFailed.test.ts.snap
Expand Up @@ -6,11 +6,9 @@ FAIL __tests__/bar.spec.js
expect(received).toBe(expected) // Object.is equality
Expected: "foo"
Received: "bar"
1 |
> 2 | test('bar 1', () => { expect('bar').toBe('foo'); });
| ^
3 |
at Object.toBe (__tests__/bar.spec.js:2:43)
> 1 | test('bar 1', () => { expect('bar').toBe('foo'); });
| ^
at Object.toBe (__tests__/bar.spec.js:1:37)
PASS __tests__/foo.spec.js
`;
Expand All @@ -22,11 +20,9 @@ FAIL __tests__/bar.spec.js
expect(received).toBe(expected) // Object.is equality
Expected: "foo"
Received: "bar"
1 |
> 2 | test('bar 1', () => { expect('bar').toBe('foo'); });
| ^
3 |
at Object.toBe (__tests__/bar.spec.js:2:43)
> 1 | test('bar 1', () => { expect('bar').toBe('foo'); });
| ^
at Object.toBe (__tests__/bar.spec.js:1:37)
`;

Expand Down
Expand Up @@ -8,11 +8,9 @@ FAIL __tests__/bar.spec.js
Snapshot name: \`bar 1\`
Snapshot: "foo"
Received: "bar"
1 |
> 2 | test('bar', () => { expect('bar').toMatchSnapshot(); });
| ^
3 |
at Object.toMatchSnapshot (__tests__/bar.spec.js:2:41)
> 1 | test('bar', () => { expect('bar').toMatchSnapshot(); });
| ^
at Object.toMatchSnapshot (__tests__/bar.spec.js:1:35)
› 1 snapshot failed.
Snapshot Summary
› 1 snapshot failed from 1 test suite. Inspect your code changes or press \`u\` to update them.
Expand Down
18 changes: 7 additions & 11 deletions e2e/__tests__/globals.test.ts
Expand Up @@ -20,7 +20,7 @@ import {
const DIR = path.resolve(tmpdir(), 'globalVariables.test');
const TEST_DIR = path.resolve(DIR, '__tests__');

function cleanStderr(stderr) {
function cleanStderr(stderr: string) {
const {rest} = extractSummary(stderr);
return rest.replace(/.*(jest-jasmine2).*\n/g, '');
}
Expand Down Expand Up @@ -141,12 +141,10 @@ FAIL __tests__/onlyConstructs.test.js
Missing second argument. It must be a callback function.
1 |
> 2 | describe('describe, no implementation');
| ^
3 |
> 1 | describe('describe, no implementation');
| ^
at Object.describe (__tests__/onlyConstructs.test.js:2:5)
at Object.describe (__tests__/onlyConstructs.test.js:1:1)
`.trim(),
);
} else {
Expand All @@ -157,12 +155,10 @@ FAIL __tests__/onlyConstructs.test.js
Missing second argument. It must be a callback function.
1 |
> 2 | describe('describe, no implementation');
| ^
3 |
> 1 | describe('describe, no implementation');
| ^
at Object.<anonymous> (__tests__/onlyConstructs.test.js:2:14)
at Object.<anonymous> (__tests__/onlyConstructs.test.js:1:10)
`.trim(),
);
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/__tests__/resolveBrowserField.test.ts
Expand Up @@ -7,6 +7,7 @@

import {tmpdir} from 'os';
import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {cleanup, writeFiles, writeSymlinks} from '../Utils';
import runJest from '../runJest';

Expand Down Expand Up @@ -61,10 +62,9 @@ test('preserves module identity for symlinks when using browser field resolution

const {stdout, stderr, exitCode} = runJest(DIR, ['--no-watchman']);
expect(stderr).toContain('Test Suites: 1 passed, 1 total');
expect(stdout).toMatchInlineSnapshot(`
" console.log packages/needs-preserved-id/index.js:2
expect(wrap(stdout.trim())).toMatchInlineSnapshot(`
console.log packages/needs-preserved-id/index.js:1
needs-preserved-id executed
"
`);
expect(exitCode).toEqual(0);
});
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -13,6 +13,7 @@
"@types/babel__core": "^7.0.0",
"@types/babel__generator": "^7.0.0",
"@types/babel__template": "^7.0.0",
"@types/dedent": "0.7.0",
"@types/jest": "24.0.2",
"@types/node": "*",
"@types/which": "^1.3.2",
Expand All @@ -29,6 +30,7 @@
"chokidar": "^3.3.0",
"codecov": "^3.0.0",
"debug": "^4.0.1",
"dedent": "^0.7.0",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-babel": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -2060,7 +2060,7 @@
dependencies:
"@types/node" "*"

"@types/dedent@^0.7.0":
"@types/dedent@0.7.0", "@types/dedent@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@types/dedent/-/dedent-0.7.0.tgz#155f339ca404e6dd90b9ce46a3f78fd69ca9b050"
integrity sha512-EGlKlgMhnLt/cM4DbUSafFdrkeJoC9Mvnj0PUCU7tFmTjMjNRT957kXCx0wYm3JuEq4o4ZsS5vG+NlkM2DMd2A==
Expand Down

0 comments on commit 2bc336b

Please sign in to comment.