diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f7f0fe829c..ae01d5fc11cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ ### Fixes +- `[jest-mock]` Fix automock for numeric function names ([#7653](https://github.com/facebook/jest/pull/7653)) - `[jest-config]` Ensure `existsSync` is only called with a string parameter ([#7607](https://github.com/facebook/jest/pull/7607)) - `[expect]` `toStrictEqual` considers sparseness of arrays. ([#7591](https://github.com/facebook/jest/pull/7591)) - `[jest-cli]` Fix empty coverage data for untested files ([#7388](https://github.com/facebook/jest/pull/7388)) diff --git a/docs/Configuration.md b/docs/Configuration.md index b3ca7a44928e..360677c7379c 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -409,7 +409,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "ts", "tsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. + +We recommend placing the extensions most commonly used in your project on the left, so if you are using TypeScript, you may want to consider moving "ts" and/or "tsx" to the beginning of the array. ### `moduleNameMapper` [object] diff --git a/e2e/Utils.js b/e2e/Utils.js index afc4d872c889..57e80a2fcd0f 100644 --- a/e2e/Utils.js +++ b/e2e/Utils.js @@ -159,7 +159,10 @@ export const extractSummary = (stdout: string) => { // remove all timestamps .replace(/\s*\(\d*\.?\d+m?s\)$/gm, ''); - return {rest, summary}; + return { + rest: rest.trim(), + summary: summary.trim(), + }; }; const sortTests = (stdout: string) => diff --git a/e2e/__tests__/__snapshots__/beforeAllFiltered.js.snap b/e2e/__tests__/__snapshots__/beforeAllFiltered.js.snap index 3ee05080e1b2..45020a37634b 100644 --- a/e2e/__tests__/__snapshots__/beforeAllFiltered.js.snap +++ b/e2e/__tests__/__snapshots__/beforeAllFiltered.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run 1`] = ` -" console.log __tests__/beforeAllFiltered.test.js:5 + console.log __tests__/beforeAllFiltered.test.js:5 beforeAll 1 console.log __tests__/beforeAllFiltered.test.js:8 @@ -15,5 +15,5 @@ exports[`Correct BeforeAll run ensures the BeforeAll of ignored suite is not run console.log __tests__/beforeAllFiltered.test.js:14 afterAll 1 -" + `; diff --git a/e2e/__tests__/__snapshots__/beforeEachQueue.js.snap b/e2e/__tests__/__snapshots__/beforeEachQueue.js.snap index 3e6c6f91d79d..98ede3375283 100644 --- a/e2e/__tests__/__snapshots__/beforeEachQueue.js.snap +++ b/e2e/__tests__/__snapshots__/beforeEachQueue.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] = ` -" console.log __tests__/beforeEachQueue.test.js:5 + console.log __tests__/beforeEachQueue.test.js:5 BeforeEach console.log __tests__/beforeEachQueue.test.js:9 @@ -15,5 +15,5 @@ exports[`Correct beforeEach order ensures the correct order for beforeEach 1`] = console.log __tests__/beforeEachQueue.test.js:17 It Bar -" + `; diff --git a/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.js.snap b/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.js.snap index f450eea10d7e..e63fb4b64c14 100644 --- a/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.js.snap +++ b/e2e/__tests__/__snapshots__/cliHandlesExactFilenames.test.js.snap @@ -1,21 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`CLI accepts exact file names if matchers matched 1`] = ` -"PASS foo/bar.spec.js +PASS foo/bar.spec.js ✓ foo Force exiting Jest -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?" +Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? `; exports[`CLI accepts exact file names if matchers matched 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites matching /.\\\\/foo\\\\/bar.spec.js/i." +Ran all test suites matching /.\\/foo\\/bar.spec.js/i. `; - -exports[`CLI accepts exact file names if matchers matched 3`] = `""`; diff --git a/e2e/__tests__/__snapshots__/console.test.js.snap b/e2e/__tests__/__snapshots__/console.test.js.snap index 88c6ec76d882..e67f28aa3c2f 100644 --- a/e2e/__tests__/__snapshots__/console.test.js.snap +++ b/e2e/__tests__/__snapshots__/console.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`console printing 1`] = ` -"PASS __tests__/console.test.js +PASS __tests__/console.test.js ● Console console.log __tests__/console.test.js:10 @@ -12,21 +12,18 @@ exports[`console printing 1`] = ` This is a warning message. console.error __tests__/console.test.js:16 This is an error message. - - -" `; exports[`console printing 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`console printing with --verbose 1`] = ` -" console.log __tests__/console.test.js:10 + console.log __tests__/console.test.js:10 This is a log message. console.info __tests__/console.test.js:12 @@ -37,52 +34,44 @@ exports[`console printing with --verbose 1`] = ` console.error __tests__/console.test.js:16 This is an error message. -" + `; exports[`console printing with --verbose 2`] = ` -"PASS __tests__/console.test.js +PASS __tests__/console.test.js ✓ works just fine - -" `; exports[`console printing with --verbose 3`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; -exports[`does not print to console with --silent 1`] = `""`; +exports[`does not print to console with --silent 1`] = ``; -exports[`does not print to console with --silent 2`] = ` -"PASS __tests__/console.test.js - -" -`; +exports[`does not print to console with --silent 2`] = `PASS __tests__/console.test.js`; exports[`does not print to console with --silent 3`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total -Time: <>" +Time: <> `; -exports[`the jsdom console is the same as the test console 1`] = `""`; +exports[`the jsdom console is the same as the test console 1`] = ``; exports[`the jsdom console is the same as the test console 2`] = ` -"PASS __tests__/console.test.js +PASS __tests__/console.test.js ✓ can mock console.error calls from jsdom - -" `; exports[`the jsdom console is the same as the test console 3`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.js.snap b/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.js.snap index 128a56ecb5a4..f8623ba1fdf0 100644 --- a/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.js.snap +++ b/e2e/__tests__/__snapshots__/consoleLogOutputWhenRunInBand.test.js.snap @@ -1,25 +1,25 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`prints console.logs when run with forceExit 1`] = ` -"PASS __tests__/a-banana.js +PASS __tests__/a-banana.js ✓ banana Force exiting Jest -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?" +Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? `; exports[`prints console.logs when run with forceExit 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +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:2 Hey -" + `; diff --git a/e2e/__tests__/__snapshots__/coverageReport.test.js.snap b/e2e/__tests__/__snapshots__/coverageReport.test.js.snap index aaf5bd50d645..ad619cfc44f1 100644 --- a/e2e/__tests__/__snapshots__/coverageReport.test.js.snap +++ b/e2e/__tests__/__snapshots__/coverageReport.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`collects coverage from duplicate files avoiding shared cache 1`] = ` -"---------------|----------|----------|----------|----------|-------------------| +---------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ---------------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | @@ -9,41 +9,41 @@ All files | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | b | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | ----------------|----------|----------|----------|----------|-------------------|" +---------------|----------|----------|----------|----------|-------------------| `; exports[`collects coverage only from multiple specified files 1`] = ` -"--------------|----------|----------|----------|----------|-------------------| +--------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | --------------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | otherFile.js | 100 | 100 | 100 | 100 | | setup.js | 100 | 100 | 100 | 100 | | ---------------|----------|----------|----------|----------|-------------------|" +--------------|----------|----------|----------|----------|-------------------| `; exports[`collects coverage only from specified file 1`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | setup.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; exports[`collects coverage only from specified files avoiding dependencies 1`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 85.71 | 100 | 50 | 100 | | sum.js | 85.71 | 100 | 50 | 100 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; -exports[`does not output coverage report when html is requested 1`] = `""`; +exports[`does not output coverage report when html is requested 1`] = ``; exports[`generates coverage when using the testRegex config param 1`] = ` -"-------------------------------------|----------|----------|----------|----------|-------------------| +-------------------------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------------------------------|----------|----------|----------|----------|-------------------| All files | 56.52 | 0 | 50 | 55.56 | | @@ -56,20 +56,19 @@ All files | 56.52 | 0 | 50 | 55.56 identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | --------------------------------------|----------|----------|----------|----------|-------------------|" +-------------------------------------|----------|----------|----------|----------|-------------------| `; exports[`json reporter printing with --coverage 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 2 passed, 3 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`outputs coverage report 1`] = ` -"-------------------------------------|----------|----------|----------|----------|-------------------| +-------------------------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------------------------------|----------|----------|----------|----------|-------------------| All files | 56.52 | 0 | 50 | 55.56 | | @@ -82,11 +81,11 @@ All files | 56.52 | 0 | 50 | 55.56 identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | --------------------------------------|----------|----------|----------|----------|-------------------|" +-------------------------------------|----------|----------|----------|----------|-------------------| `; exports[`outputs coverage report when text and text-summary is requested 1`] = ` -" + =============================== Coverage summary =============================== Statements : 56.52% ( 13/23 ) Branches : 0% ( 0/4 ) @@ -106,11 +105,11 @@ All files | 56.52 | 0 | 50 | 55.56 identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | --------------------------------------|----------|----------|----------|----------|-------------------|" +-------------------------------------|----------|----------|----------|----------|-------------------| `; exports[`outputs coverage report when text is requested 1`] = ` -"-------------------------------------|----------|----------|----------|----------|-------------------| +-------------------------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------------------------------|----------|----------|----------|----------|-------------------| All files | 56.52 | 0 | 50 | 55.56 | | @@ -123,15 +122,15 @@ All files | 56.52 | 0 | 50 | 55.56 identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | identical.js | 100 | 100 | 100 | 100 | | --------------------------------------|----------|----------|----------|----------|-------------------|" +-------------------------------------|----------|----------|----------|----------|-------------------| `; exports[`outputs coverage report when text-summary is requested 1`] = ` -" + =============================== Coverage summary =============================== Statements : 56.52% ( 13/23 ) Branches : 0% ( 0/4 ) Functions : 50% ( 3/6 ) Lines : 55.56% ( 10/18 ) -================================================================================" +================================================================================ `; diff --git a/e2e/__tests__/__snapshots__/coverageThreshold.test.js.snap b/e2e/__tests__/__snapshots__/coverageThreshold.test.js.snap index eb85e0a51a21..d5b0d7314d48 100644 --- a/e2e/__tests__/__snapshots__/coverageThreshold.test.js.snap +++ b/e2e/__tests__/__snapshots__/coverageThreshold.test.js.snap @@ -1,121 +1,113 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`excludes tests matched by path threshold groups from global group 1`] = ` -"PASS __tests__/banana.test.js +PASS __tests__/banana.test.js ✓ banana -Jest: \\"global\\" coverage threshold for lines (100%) not met: 0% -" +Jest: "global" coverage threshold for lines (100%) not met: 0% `; exports[`excludes tests matched by path threshold groups from global group 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`excludes tests matched by path threshold groups from global group: stdout 1`] = ` -"-----------|----------|----------|----------|----------|-------------------| +-----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -----------|----------|----------|----------|----------|-------------------| All files | 50 | 100 | 50 | 50 | | apple.js | 0 | 100 | 0 | 0 | 2,3 | banana.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------| -" + `; exports[`exits with 0 if global threshold group is not found in coverage data: stdout 1`] = ` -"-----------|----------|----------|----------|----------|-------------------| +-----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | banana.js | 100 | 100 | 100 | 100 | | ------------|----------|----------|----------|----------|-------------------|" +-----------|----------|----------|----------|----------|-------------------| `; exports[`exits with 1 if coverage threshold is not met 1`] = ` -"PASS __tests__/a-banana.js +PASS __tests__/a-banana.js ✓ banana -Jest: \\"global\\" coverage threshold for lines (90%) not met: 50% -" +Jest: "global" coverage threshold for lines (90%) not met: 50% `; exports[`exits with 1 if coverage threshold is not met 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; 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 | ----------------|----------|----------|----------|----------|-------------------| -" + `; exports[`exits with 1 if path threshold group is not found in coverage data 1`] = ` -"PASS __tests__/banana.test.js +PASS __tests__/banana.test.js ✓ banana Jest: Coverage data for apple.js was not found. -" `; exports[`exits with 1 if path threshold group is not found in coverage data 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`exits with 1 if path threshold group is not found in coverage data: stdout 1`] = ` -"-----------|----------|----------|----------|----------|-------------------| +-----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | banana.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------| -" + `; exports[`file is matched by all path and glob threshold groups 1`] = ` -"PASS __tests__/banana.test.js +PASS __tests__/banana.test.js ✓ banana -Jest: \\"./\\" coverage threshold for lines (100%) not met: 50% -Jest: \\"<>\\" coverage threshold for lines (100%) not met: 50% -Jest: \\"./banana.js\\" coverage threshold for lines (100%) not met: 50% -" +Jest: "./" coverage threshold for lines (100%) not met: 50% +Jest: "<>" coverage threshold for lines (100%) not met: 50% +Jest: "./banana.js" coverage threshold for lines (100%) not met: 50% `; exports[`file is matched by all path and glob threshold groups 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; 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 | -----------|----------|----------|----------|----------|-------------------| -" + `; diff --git a/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap b/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap index 49b4afe4098c..8faa1ffd5ebd 100644 --- a/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap +++ b/e2e/__tests__/__snapshots__/customMatcherStackTrace.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`works with custom matchers 1`] = ` -"FAIL __tests__/customMatcher.test.js +FAIL __tests__/customMatcher.test.js Custom matcher ✓ passes ✓ fails @@ -25,6 +25,4 @@ exports[`works with custom matchers 1`] = ` at foo (__tests__/customMatcher.test.js:52:7) at Object.callback (__tests__/customMatcher.test.js:11:18) at Object.toCustomMatch (__tests__/customMatcher.test.js:53:8) - -" `; diff --git a/e2e/__tests__/__snapshots__/customReporters.test.js.snap b/e2e/__tests__/__snapshots__/customReporters.test.js.snap index c1832808c3f4..a6e6b8a32e91 100644 --- a/e2e/__tests__/__snapshots__/customReporters.test.js.snap +++ b/e2e/__tests__/__snapshots__/customReporters.test.js.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Custom Reporters Integration IncompleteReporter for flexibility 1`] = ` -"onRunComplete is called +onRunComplete is called Passed Tests: 1 Failed Tests: 0 -Total Tests: 1" +Total Tests: 1 `; exports[`Custom Reporters Integration TestReporter with all tests failing 1`] = ` @@ -64,19 +64,17 @@ Object { `; exports[`Custom Reporters Integration default reporters enabled 1`] = ` -"PASS __tests__/add.test.js +PASS __tests__/add.test.js Custom Reporters ✓ adds ok - -" `; exports[`Custom Reporters Integration default reporters enabled 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites matching /add.test.js/i." +Ran all test suites matching /add.test.js/i. `; exports[`Custom Reporters Integration default reporters enabled 3`] = ` @@ -104,7 +102,7 @@ Object { `; exports[`Custom Reporters Integration invalid format for adding reporters 1`] = ` -"● Reporter Validation Error: +● Reporter Validation Error: Unexpected value for Path at index 0 of reporter at index 0 Expected: @@ -119,31 +117,31 @@ exports[`Custom Reporters Integration invalid format for adding reporters 1`] = Configuration Documentation: https://jestjs.io/docs/configuration.html -" + `; exports[`Custom Reporters Integration valid array format for adding reporters 1`] = ` -"{ - \\"onRunComplete\\": { - \\"called\\": true, - \\"numPassedTests\\": 1, - \\"numFailedTests\\": 0, - \\"numTotalTests\\": 1 +{ + "onRunComplete": { + "called": true, + "numPassedTests": 1, + "numFailedTests": 0, + "numTotalTests": 1 }, - \\"onRunStart\\": { - \\"called\\": true, - \\"options\\": \\"object\\" + "onRunStart": { + "called": true, + "options": "object" }, - \\"onTestResult\\": { - \\"times\\": 1, - \\"called\\": true + "onTestResult": { + "times": 1, + "called": true }, - \\"onTestStart\\": { - \\"called\\": true, - \\"path\\": false + "onTestStart": { + "called": true, + "path": false }, - \\"options\\": { - \\"Dmitrii Abramov\\": \\"Awesome\\" + "options": { + "Dmitrii Abramov": "Awesome" } -}" +} `; diff --git a/e2e/__tests__/__snapshots__/detectOpenHandles.js.snap b/e2e/__tests__/__snapshots__/detectOpenHandles.js.snap index 3d78afc98b08..bf7c5f83b396 100644 --- a/e2e/__tests__/__snapshots__/detectOpenHandles.js.snap +++ b/e2e/__tests__/__snapshots__/detectOpenHandles.js.snap @@ -1,19 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`prints message about flag on forceExit 1`] = ` -"Force exiting Jest +Force exiting Jest -Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?" +Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished? `; exports[`prints message about flag on slow tests 1`] = ` -"Jest did not exit one second after the test run has completed. +Jest did not exit one second after the test run has completed. -This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with \`--detectOpenHandles\` to troubleshoot this issue." +This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with \`--detectOpenHandles\` to troubleshoot this issue. `; exports[`prints out info about open handlers 1`] = ` -"Jest has detected the following 1 open handle potentially keeping Jest from exiting: +Jest has detected the following 1 open handle potentially keeping Jest from exiting: ● GETADDRINFOREQWRAP @@ -24,11 +24,11 @@ exports[`prints out info about open handlers 1`] = ` 10 | at Object.listen (server.js:9:5) - at Object.require (__tests__/outside.js:3:1)" + at Object.require (__tests__/outside.js:3:1) `; exports[`prints out info about open handlers from inside tests 1`] = ` -"Jest has detected the following 1 open handle potentially keeping Jest from exiting: +Jest has detected the following 1 open handle potentially keeping Jest from exiting: ● Timeout @@ -40,5 +40,5 @@ exports[`prints out info about open handlers from inside tests 1`] = ` 6 | }); 7 | - at Object.setTimeout (__tests__/inside.js:4:3)" + at Object.setTimeout (__tests__/inside.js:4:3) `; diff --git a/e2e/__tests__/__snapshots__/each.test.js.snap b/e2e/__tests__/__snapshots__/each.test.js.snap index 662a0870b471..75220531c419 100644 --- a/e2e/__tests__/__snapshots__/each.test.js.snap +++ b/e2e/__tests__/__snapshots__/each.test.js.snap @@ -1,15 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`formats args with pretty format when given %p 1`] = ` -"PASS __tests__/pretty.test.js +PASS __tests__/pretty.test.js array - ✓ \\"hello\\" == \\"hello\\" + ✓ "hello" == "hello" ✓ 1 == 1 ✓ null == null ✓ undefined == undefined ✓ 1.2 == 1.2 - ✓ {\\"foo\\": \\"bar\\"} == {\\"foo\\": \\"bar\\"} - ✓ {\\"foo\\": [Object]} == {\\"foo\\": [Object]} + ✓ {"foo": "bar"} == {"foo": "bar"} + ✓ {"foo": [Object]} == {"foo": [Object]} ✓ [Function noop] == [Function noop] ✓ [] == [] ✓ [[Object]] == [[Object]] @@ -17,36 +17,32 @@ exports[`formats args with pretty format when given %p 1`] = ` ✓ -Infinity == -Infinity ✓ NaN == NaN template - ✓ \\"hello\\" == \\"hello\\" + ✓ "hello" == "hello" ✓ 1 == 1 ✓ null == null ✓ undefined == undefined ✓ 1.2 == 1.2 - ✓ {\\"foo\\": \\"bar\\"} == {\\"foo\\": \\"bar\\"} - ✓ {\\"foo\\": [Object]} == {\\"foo\\": [Object]} + ✓ {"foo": "bar"} == {"foo": "bar"} + ✓ {"foo": [Object]} == {"foo": [Object]} ✓ [Function noop] == [Function noop] ✓ [] == [] ✓ [[Object]] == [[Object]] ✓ Infinity == Infinity ✓ -Infinity == -Infinity ✓ NaN == NaN - -" `; exports[`runs only the describe.only.each tests 1`] = ` -"PASS __tests__/describeOnly.test.js +PASS __tests__/describeOnly.test.js passes all rows expected true == true ✓ passes ✓ passes fails all rows expected false == true ○ skipped 1 test - -" `; exports[`shows error message when not enough arguments are supplied to tests 1`] = ` -"FAIL __tests__/eachException.test.js +FAIL __tests__/eachException.test.js ✕ throws exception when one argument too few are supplied $left == $right ✕ throws exception when not enough arguments are supplied $left == $right @@ -96,23 +92,19 @@ exports[`shows error message when not enough arguments are supplied to tests 1`] 22 | \`( at Object. (__tests__/eachException.test.js:19:1) - -" `; exports[`shows only the tests with .only as being ran 1`] = ` -"PASS __tests__/eachOnly.test.js +PASS __tests__/eachOnly.test.js ✓ passes one row expected true == true ✓ passes one row expected true == true ✓ passes one row expected true == true ✓ passes one row expected true == true ○ skipped 4 tests - -" `; exports[`shows only the tests without .skip as being ran 1`] = ` -"PASS __tests__/eachSkip.test.js +PASS __tests__/eachSkip.test.js ✓ passes one row expected true == true ✓ passes one row expected true == true ✓ passes one row expected true == true @@ -120,12 +112,10 @@ exports[`shows only the tests without .skip as being ran 1`] = ` ○ skipped 4 tests passes all rows expected true == true ○ skipped 2 tests - -" `; exports[`shows the correct errors in stderr when failing tests 1`] = ` -"FAIL __tests__/failure.test.js +FAIL __tests__/failure.test.js ✓ array table fails on one row: expected true == true ✕ array table fails on one row: expected true == false ✕ array table fails on all rows expected 1 == 2 @@ -137,9 +127,9 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` ✕ The word red contains the letter 'z' ✕ The word green contains the letter 'z' ✕ The word bean contains the letter 'z' - template table describe fails on all rows expected \\"a\\" == \\"b\\" + template table describe fails on all rows expected "a" == "b" ✕ fails - template table describe fails on all rows expected \\"c\\" == \\"d\\" + template table describe fails on all rows expected "c" == "d" ✕ fails array table describe fails on all rows expected a == b ✕ fails @@ -255,7 +245,7 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` Expected: true Received: false - 45 | \\"The word %s contains the letter 'z'\\", + 45 | "The word %s contains the letter 'z'", 46 | word => { > 47 | expect(/z/.test(word)).toBe(true); | ^ @@ -272,7 +262,7 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` Expected: true Received: false - 45 | \\"The word %s contains the letter 'z'\\", + 45 | "The word %s contains the letter 'z'", 46 | word => { > 47 | expect(/z/.test(word)).toBe(true); | ^ @@ -289,7 +279,7 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` Expected: true Received: false - 45 | \\"The word %s contains the letter 'z'\\", + 45 | "The word %s contains the letter 'z'", 46 | word => { > 47 | expect(/z/.test(word)).toBe(true); | ^ @@ -299,12 +289,12 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` at toBe (__tests__/failure.test.js:47:28) - ● template table describe fails on all rows expected \\"a\\" == \\"b\\" › fails + ● template table describe fails on all rows expected "a" == "b" › fails expect(received).toBe(expected) // Object.is equality - Expected: \\"b\\" - Received: \\"a\\" + Expected: "b" + Received: "a" 57 | ({left, right}) => { 58 | it('fails ', () => { @@ -316,12 +306,12 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` at Object.toBe (__tests__/failure.test.js:59:20) - ● template table describe fails on all rows expected \\"c\\" == \\"d\\" › fails + ● template table describe fails on all rows expected "c" == "d" › fails expect(received).toBe(expected) // Object.is equality - Expected: \\"d\\" - Received: \\"c\\" + Expected: "d" + Received: "c" 57 | ({left, right}) => { 58 | it('fails ', () => { @@ -337,8 +327,8 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` expect(received).toBe(expected) // Object.is equality - Expected: \\"b\\" - Received: \\"a\\" + Expected: "b" + Received: "a" 66 | (left, right) => { 67 | it('fails', () => { @@ -354,8 +344,8 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` expect(received).toBe(expected) // Object.is equality - Expected: \\"d\\" - Received: \\"c\\" + Expected: "d" + Received: "c" 66 | (left, right) => { 67 | it('fails', () => { @@ -366,6 +356,4 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` 71 | ); at Object.toBe (__tests__/failure.test.js:68:20) - -" `; diff --git a/e2e/__tests__/__snapshots__/emptyDescribeWithHooks.test.js.snap b/e2e/__tests__/__snapshots__/emptyDescribeWithHooks.test.js.snap index 4c8744c30973..af198cb7e29a 100644 --- a/e2e/__tests__/__snapshots__/emptyDescribeWithHooks.test.js.snap +++ b/e2e/__tests__/__snapshots__/emptyDescribeWithHooks.test.js.snap @@ -29,15 +29,12 @@ Object { 12 | describe('another block with tests', () => { at beforeEach (__tests__/hookInEmptyDescribe.test.js:9:3) - at Object.describe (__tests__/hookInEmptyDescribe.test.js:8:1) - -", + at Object.describe (__tests__/hookInEmptyDescribe.test.js:8:1)", "summary": "Test Suites: 1 failed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites matching /hookInEmptyDescribe.test.js/i. -", +Ran all test suites matching /hookInEmptyDescribe.test.js/i.", } `; @@ -59,15 +56,12 @@ Object { 12 | at beforeEach (__tests__/hookInEmptyNestedDescribe.test.js:9:3) - at Object.describe (__tests__/hookInEmptyNestedDescribe.test.js:8:1) - -", + at Object.describe (__tests__/hookInEmptyNestedDescribe.test.js:8:1)", "summary": "Test Suites: 1 failed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites matching /hookInEmptyNestedDescribe.test.js/i. -", +Ran all test suites matching /hookInEmptyNestedDescribe.test.js/i.", } `; @@ -134,14 +128,11 @@ Object { 15 | describe('another block with tests', () => { at beforeAll (__tests__/multipleHooksInEmptyDescribe.test.js:12:3) - at Object.describe (__tests__/multipleHooksInEmptyDescribe.test.js:8:1) - -", + at Object.describe (__tests__/multipleHooksInEmptyDescribe.test.js:8:1)", "summary": "Test Suites: 1 failed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites matching /multipleHooksInEmptyDescribe.test.js/i. -", +Ran all test suites matching /multipleHooksInEmptyDescribe.test.js/i.", } `; diff --git a/e2e/__tests__/__snapshots__/errorOnDeprecated.test.js.snap b/e2e/__tests__/__snapshots__/errorOnDeprecated.test.js.snap index e2857a9525b7..9ca3c1100c97 100644 --- a/e2e/__tests__/__snapshots__/errorOnDeprecated.test.js.snap +++ b/e2e/__tests__/__snapshots__/errorOnDeprecated.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`defaultTimeoutInterval.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/defaultTimeoutInterval.test.js +FAIL __tests__/defaultTimeoutInterval.test.js ✕ Default Timeout Interval ● Default Timeout Interval @@ -17,12 +17,10 @@ exports[`defaultTimeoutInterval.test.js errors in errorOnDeprecated mode 1`] = ` 13 | at Object..test (__tests__/defaultTimeoutInterval.test.js:10:3) - -" `; exports[`fail.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/fail.test.js +FAIL __tests__/fail.test.js ✕ fail ● fail @@ -38,12 +36,10 @@ exports[`fail.test.js errors in errorOnDeprecated mode 1`] = ` 16 | at Object.fail (__tests__/fail.test.js:13:5) - -" `; exports[`jasmine.addMatchers.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.addMatchers.test.js +FAIL __tests__/jasmine.addMatchers.test.js ● Test suite failed to run Illegal usage of \`jasmine.addMatchers\`, prefer \`expect.extends\`. @@ -57,12 +53,10 @@ exports[`jasmine.addMatchers.test.js errors in errorOnDeprecated mode 1`] = ` 12 | message: 'Nobdy expects the Spanish Inquisition!', at Object.addMatchers (__tests__/jasmine.addMatchers.test.js:9:9) - -" `; exports[`jasmine.any.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.any.test.js +FAIL __tests__/jasmine.any.test.js ✕ jasmine.any ● jasmine.any @@ -77,12 +71,10 @@ exports[`jasmine.any.test.js errors in errorOnDeprecated mode 1`] = ` 12 | at Object.any (__tests__/jasmine.any.test.js:10:51) - -" `; exports[`jasmine.anything.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.anything.test.js +FAIL __tests__/jasmine.anything.test.js ✕ jasmine.anything ● jasmine.anything @@ -97,12 +89,10 @@ exports[`jasmine.anything.test.js errors in errorOnDeprecated mode 1`] = ` 12 | at Object.anything (__tests__/jasmine.anything.test.js:10:62) - -" `; exports[`jasmine.arrayContaining.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.arrayContaining.test.js +FAIL __tests__/jasmine.arrayContaining.test.js ✕ jasmine.arrayContaining ● jasmine.arrayContaining @@ -117,12 +107,10 @@ exports[`jasmine.arrayContaining.test.js errors in errorOnDeprecated mode 1`] = 12 | at Object.arrayContaining (__tests__/jasmine.arrayContaining.test.js:10:45) - -" `; exports[`jasmine.createSpy.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.createSpy.test.js +FAIL __tests__/jasmine.createSpy.test.js ✕ jasmine.createSpy ● jasmine.createSpy @@ -138,12 +126,10 @@ exports[`jasmine.createSpy.test.js errors in errorOnDeprecated mode 1`] = ` 13 | }); at Object.createSpy (__tests__/jasmine.createSpy.test.js:10:25) - -" `; exports[`jasmine.objectContaining.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.objectContaining.test.js +FAIL __tests__/jasmine.objectContaining.test.js ✕ jasmine.objectContaining ● jasmine.objectContaining @@ -159,12 +145,10 @@ exports[`jasmine.objectContaining.test.js errors in errorOnDeprecated mode 1`] = 14 | at Object.objectContaining (__tests__/jasmine.objectContaining.test.js:11:13) - -" `; exports[`jasmine.stringMatching.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/jasmine.stringMatching.test.js +FAIL __tests__/jasmine.stringMatching.test.js ✕ jasmine.stringMatching ● jasmine.stringMatching @@ -179,12 +163,10 @@ exports[`jasmine.stringMatching.test.js errors in errorOnDeprecated mode 1`] = ` 12 | at Object.stringMatching (__tests__/jasmine.stringMatching.test.js:10:50) - -" `; exports[`pending.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/pending.test.js +FAIL __tests__/pending.test.js ✕ pending ● pending @@ -200,12 +182,10 @@ exports[`pending.test.js errors in errorOnDeprecated mode 1`] = ` 14 | }); at Object.pending (__tests__/pending.test.js:11:5) - -" `; exports[`spyOn.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/spyOn.test.js +FAIL __tests__/spyOn.test.js ✕ spyOn ● spyOn @@ -221,12 +201,10 @@ exports[`spyOn.test.js errors in errorOnDeprecated mode 1`] = ` 18 | at Object.spyOn (__tests__/spyOn.test.js:15:3) - -" `; exports[`spyOnProperty.test.js errors in errorOnDeprecated mode 1`] = ` -"FAIL __tests__/spyOnProperty.test.js +FAIL __tests__/spyOnProperty.test.js ✕ spyOnProperty ● spyOnProperty @@ -242,6 +220,4 @@ exports[`spyOnProperty.test.js errors in errorOnDeprecated mode 1`] = ` 27 | at Object.spyOnProperty (__tests__/spyOnProperty.test.js:24:15) - -" `; diff --git a/e2e/__tests__/__snapshots__/executeTestsOnceInMpr.js.snap b/e2e/__tests__/__snapshots__/executeTestsOnceInMpr.js.snap index 90f90fe3c30b..39ebcb0c37c3 100644 --- a/e2e/__tests__/__snapshots__/executeTestsOnceInMpr.js.snap +++ b/e2e/__tests__/__snapshots__/executeTestsOnceInMpr.js.snap @@ -1,8 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Tests are executed only once even in an MPR 1`] = ` -"PASS foo/folder/my-test-bar.js +PASS foo/folder/my-test-bar.js ✓ bar - -" `; diff --git a/e2e/__tests__/__snapshots__/expectAsyncMatcher.test.js.snap b/e2e/__tests__/__snapshots__/expectAsyncMatcher.test.js.snap index c1e0cd858c93..6ef5f68f3fca 100644 --- a/e2e/__tests__/__snapshots__/expectAsyncMatcher.test.js.snap +++ b/e2e/__tests__/__snapshots__/expectAsyncMatcher.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`shows the correct errors in stderr when failing tests 1`] = ` -"FAIL __tests__/failure.test.js +FAIL __tests__/failure.test.js ✕ fail with expected non promise values ✕ fail with expected non promise values and not ✕ fail with expected promise values @@ -72,6 +72,4 @@ exports[`shows the correct errors in stderr when failing tests 1`] = ` at _next (__tests__/failure.test.js:13:194) at __tests__/failure.test.js:13:364 at Object. (__tests__/failure.test.js:13:97) - -" `; diff --git a/e2e/__tests__/__snapshots__/failures.test.js.snap b/e2e/__tests__/__snapshots__/failures.test.js.snap index 4955ba573aae..41ff2da7a002 100644 --- a/e2e/__tests__/__snapshots__/failures.test.js.snap +++ b/e2e/__tests__/__snapshots__/failures.test.js.snap @@ -1,34 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`not throwing Error objects 1`] = ` -"FAIL __tests__/throwNumber.test.js +FAIL __tests__/throwNumber.test.js ● Test suite failed to run - Expected an Error, but \\"1\\" was thrown - -" + Expected an Error, but "1" was thrown `; exports[`not throwing Error objects 2`] = ` -"FAIL __tests__/throwString.test.js +FAIL __tests__/throwString.test.js ● Test suite failed to run banana - -" `; exports[`not throwing Error objects 3`] = ` -"FAIL __tests__/throwObject.test.js +FAIL __tests__/throwObject.test.js ● Test suite failed to run Error: No message was provided - -" `; exports[`not throwing Error objects 4`] = ` -"FAIL __tests__/assertionCount.test.js +FAIL __tests__/assertionCount.test.js .assertions() ✕ throws ✕ throws on redeclare of assertion count @@ -115,12 +109,10 @@ exports[`not throwing Error objects 4`] = ` 30 | describe('.assertions()', () => { at Object.hasAssertions (__tests__/assertionCount.test.js:27:10) - -" `; exports[`not throwing Error objects 5`] = ` -"FAIL __tests__/duringTests.test.js +FAIL __tests__/duringTests.test.js ✕ Promise thrown during test ✕ Boolean thrown during test ✕ undefined thrown during test @@ -175,10 +167,10 @@ exports[`not throwing Error objects 5`] = ` ● Object thrown during test thrown: Object { - \\"notAnError\\": Array [ + "notAnError": Array [ Object { - \\"hello\\": true, - \\"tooDeep\\": [Object], + "hello": true, + "tooDeep": [Object], }, ], } @@ -224,10 +216,10 @@ exports[`not throwing Error objects 5`] = ` ● done(non-error) thrown: Object { - \\"notAnError\\": Array [ + "notAnError": Array [ Object { - \\"hello\\": true, - \\"tooDeep\\": [Object], + "hello": true, + "tooDeep": [Object], }, ], } @@ -245,10 +237,10 @@ exports[`not throwing Error objects 5`] = ` ● returned promise rejection thrown: Object { - \\"notAnError\\": Array [ + "notAnError": Array [ Object { - \\"hello\\": true, - \\"tooDeep\\": [Object], + "hello": true, + "tooDeep": [Object], }, ], } @@ -260,12 +252,10 @@ exports[`not throwing Error objects 5`] = ` 41 | at Object.test (__tests__/duringTests.test.js:40:1) - -" `; exports[`works with assertions in separate files 1`] = ` -"FAIL __tests__/testMacro.test.js +FAIL __tests__/testMacro.test.js ✕ use some imported macro to make assertion ● use some imported macro to make assertion @@ -284,12 +274,10 @@ exports[`works with assertions in separate files 1`] = ` at toEqual (macros.js:12:15) at Object.shouldEqual (__tests__/testMacro.test.js:14:3) - -" `; exports[`works with async failures 1`] = ` -"FAIL __tests__/asyncFailures.test.js +FAIL __tests__/asyncFailures.test.js ✕ resolve, but fail ✕ reject, but fail ✕ expect reject @@ -306,8 +294,8 @@ exports[`works with async failures 1`] = ` + Received Object { - - \\"baz\\": \\"bar\\", - + \\"foo\\": \\"bar\\", + - "baz": "bar", + + "foo": "bar", } 10 | @@ -330,8 +318,8 @@ exports[`works with async failures 1`] = ` + Received Object { - - \\"baz\\": \\"bar\\", - + \\"foo\\": \\"bar\\", + - "baz": "bar", + + "foo": "bar", } 13 | @@ -349,7 +337,7 @@ exports[`works with async failures 1`] = ` expect(received).rejects.toEqual() Received promise resolved instead of rejected - Resolved to value: {\\"foo\\": \\"bar\\"} + Resolved to value: {"foo": "bar"} 16 | 17 | test('expect reject', () => @@ -366,7 +354,7 @@ exports[`works with async failures 1`] = ` expect(received).resolves.toEqual() Received promise rejected instead of resolved - Rejected to value: {\\"foo\\": \\"bar\\"} + Rejected to value: {"foo": "bar"} 19 | 20 | test('expect resolve', () => @@ -391,25 +379,23 @@ exports[`works with async failures 1`] = ` 26 | at Object.test (__tests__/asyncFailures.test.js:23:1) - -" `; exports[`works with named snapshot failures 1`] = ` -"FAIL __tests__/snapshotNamed.test.js +FAIL __tests__/snapshotNamed.test.js ✕ failing named snapshot ● failing named snapshot expect(value).toMatchSnapshot() - Received value does not match stored snapshot \\"failing named snapshot: snapname 1\\". + Received value does not match stored snapshot "failing named snapshot: snapname 1". - Snapshot + Received - - \\"bar\\" - + \\"foo\\" + - "bar" + + "foo" 10 | 11 | test('failing named snapshot', () => { @@ -421,11 +407,11 @@ exports[`works with named snapshot failures 1`] = ` at Object.toMatchSnapshot (__tests__/snapshotNamed.test.js:12:17) › 1 snapshot failed. -" + `; exports[`works with node assert 1`] = ` -"FAIL __tests__/assertionError.test.js +FAIL __tests__/assertionError.test.js ✕ assert ✕ assert with a message ✕ assert.ok @@ -573,9 +559,9 @@ exports[`works with node assert 1`] = ` assert.deepEqual(received, expected) Expected value to deeply equal to: - {\\"a\\": {\\"b\\": {\\"c\\": 6}}} + {"a": {"b": {"c": 6}}} Received: - {\\"a\\": {\\"b\\": {\\"c\\": 5}}} + {"a": {"b": {"c": 5}}} Difference: @@ -583,10 +569,10 @@ exports[`works with node assert 1`] = ` + Received Object { - \\"a\\": Object { - \\"b\\": Object { - - \\"c\\": 6, - + \\"c\\": 5, + "a": Object { + "b": Object { + - "c": 6, + + "c": 5, }, }, } @@ -606,9 +592,9 @@ exports[`works with node assert 1`] = ` assert.deepEqual(received, expected) Expected value to deeply equal to: - {\\"a\\": {\\"b\\": {\\"c\\": 7}}} + {"a": {"b": {"c": 7}}} Received: - {\\"a\\": {\\"b\\": {\\"c\\": 5}}} + {"a": {"b": {"c": 5}}} Message: this is a message @@ -619,10 +605,10 @@ exports[`works with node assert 1`] = ` + Received Object { - \\"a\\": Object { - \\"b\\": Object { - - \\"c\\": 7, - + \\"c\\": 5, + "a": Object { + "b": Object { + - "c": 7, + + "c": 5, }, }, } @@ -642,9 +628,9 @@ exports[`works with node assert 1`] = ` assert.notDeepEqual(received, expected) Expected value not to deeply equal to: - {\\"a\\": 1} + {"a": 1} Received: - {\\"a\\": 1} + {"a": 1} Difference: @@ -710,9 +696,9 @@ exports[`works with node assert 1`] = ` assert.deepStrictEqual(received, expected) Expected value to deeply and strictly equal to: - {\\"a\\": 2} + {"a": 2} Received: - {\\"a\\": 1} + {"a": 1} Difference: @@ -720,8 +706,8 @@ exports[`works with node assert 1`] = ` + Received Object { - - \\"a\\": 2, - + \\"a\\": 1, + - "a": 2, + + "a": 1, } 57 | @@ -739,9 +725,9 @@ exports[`works with node assert 1`] = ` assert.notDeepStrictEqual(received, expected) Expected value not to deeply and strictly equal to: - {\\"a\\": 1} + {"a": 1} Received: - {\\"a\\": 1} + {"a": 1} Difference: @@ -805,10 +791,10 @@ exports[`works with node assert 1`] = ` assert.equal(received, expected) or assert(received) Expected value to be equal to: - \\"hello\\" + "hello" Received: - \\"hello - goodbye\\" + "hello + goodbye" Message: hmmm @@ -823,7 +809,7 @@ exports[`works with node assert 1`] = ` 79 | 80 | test('async', async () => { - > 81 | assert.equal('hello\\\\ngoodbye', 'hello', 'hmmm'); + > 81 | assert.equal('hello\\ngoodbye', 'hello', 'hmmm'); | ^ 82 | }); 83 | @@ -833,25 +819,23 @@ exports[`works with node assert 1`] = ` at _next (__tests__/assertionError.test.js:13:194) at __tests__/assertionError.test.js:13:364 at Object. (__tests__/assertionError.test.js:13:97) - -" `; exports[`works with snapshot failures 1`] = ` -"FAIL __tests__/snapshot.test.js +FAIL __tests__/snapshot.test.js ✕ failing snapshot ● failing snapshot expect(value).toMatchSnapshot() - Received value does not match stored snapshot \\"failing snapshot 1\\". + Received value does not match stored snapshot "failing snapshot 1". - Snapshot + Received - - \\"bar\\" - + \\"foo\\" + - "bar" + + "foo" 10 | 11 | test('failing snapshot', () => { @@ -863,5 +847,5 @@ exports[`works with snapshot failures 1`] = ` at Object.toMatchSnapshot (__tests__/snapshot.test.js:12:17) › 1 snapshot failed. -" + `; diff --git a/e2e/__tests__/__snapshots__/findRelatedFiles.test.js.snap b/e2e/__tests__/__snapshots__/findRelatedFiles.test.js.snap index bde29e5dd035..d0183e881440 100644 --- a/e2e/__tests__/__snapshots__/findRelatedFiles.test.js.snap +++ b/e2e/__tests__/__snapshots__/findRelatedFiles.test.js.snap @@ -1,74 +1,68 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`--findRelatedTests flag coverage configuration is applied correctly 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites related to files matching /a.js|b.js/i." +Ran all test suites related to files matching /a.js|b.js/i. `; exports[`--findRelatedTests flag coverage configuration is applied correctly 2`] = ` -" - PASS __tests__/a.test.js -✓ a" +✓ a `; exports[`--findRelatedTests flag coverage configuration is applied correctly 3`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | a.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; exports[`--findRelatedTests flag generates coverage report for filename 1`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 2 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`--findRelatedTests flag generates coverage report for filename 2`] = ` -" - PASS __tests__/a.test.js -PASS __tests__/b.test.js" +PASS __tests__/b.test.js `; exports[`--findRelatedTests flag generates coverage report for filename 3`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | a.js | 100 | 100 | 100 | 100 | | b.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; exports[`--findRelatedTests flag generates coverage report for filename 4`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites related to files matching /a.js/i." +Ran all test suites related to files matching /a.js/i. `; exports[`--findRelatedTests flag generates coverage report for filename 5`] = ` -"PASS __tests__/a.test.js +PASS __tests__/a.test.js ✓ a - -" `; exports[`--findRelatedTests flag generates coverage report for filename 6`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | a.js | 100 | 100 | 100 | 100 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; diff --git a/e2e/__tests__/__snapshots__/globals.test.js.snap b/e2e/__tests__/__snapshots__/globals.test.js.snap index be32c136475a..e284281a7e69 100644 --- a/e2e/__tests__/__snapshots__/globals.test.js.snap +++ b/e2e/__tests__/__snapshots__/globals.test.js.snap @@ -1,26 +1,24 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`basic test constructs 1`] = ` -"PASS __tests__/basic.testConstructs.test.js +PASS __tests__/basic.testConstructs.test.js ✓ it ✓ test describe ✓ it ✓ test - -" `; exports[`basic test constructs 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 4 passed, 4 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`cannot have describe with no implementation 1`] = ` -"FAIL __tests__/onlyConstructs.test.js +FAIL __tests__/onlyConstructs.test.js ● Test suite failed to run Missing second argument. It must be a callback function. @@ -31,21 +29,18 @@ exports[`cannot have describe with no implementation 1`] = ` 3 | at Object. (__tests__/onlyConstructs.test.js:2:14) - -" `; exports[`cannot have describe with no implementation 2`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`cannot test with no implementation 1`] = ` -"FAIL __tests__/onlyConstructs.test.js +FAIL __tests__/onlyConstructs.test.js ● Test suite failed to run Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder. @@ -58,21 +53,18 @@ exports[`cannot test with no implementation 1`] = ` 5 | at Object.it (__tests__/onlyConstructs.test.js:3:5) - -" `; exports[`cannot test with no implementation 2`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`cannot test with no implementation with expand arg 1`] = ` -"FAIL __tests__/onlyConstructs.test.js +FAIL __tests__/onlyConstructs.test.js ● Test suite failed to run Missing second argument. It must be a callback function. Perhaps you want to use \`test.todo\` for a test placeholder. @@ -85,37 +77,32 @@ exports[`cannot test with no implementation with expand arg 1`] = ` 5 | at Object.it (__tests__/onlyConstructs.test.js:3:5) - -" `; exports[`cannot test with no implementation with expand arg 2`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`function as descriptor 1`] = ` -"PASS __tests__/functionAsDescriptor.test.js +PASS __tests__/functionAsDescriptor.test.js Foo ✓ it - -" `; exports[`function as descriptor 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`only 1`] = ` -"PASS __tests__/onlyConstructs.test.js +PASS __tests__/onlyConstructs.test.js ✓ test.only ✓ it.only ✓ fit @@ -127,20 +114,18 @@ exports[`only 1`] = ` ✓ test describe ✓ test - -" `; exports[`only 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 skipped, 7 passed, 8 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`only with expand arg 1`] = ` -"PASS __tests__/onlyConstructs.test.js +PASS __tests__/onlyConstructs.test.js ○ it ✓ test.only ✓ it.only @@ -152,20 +137,18 @@ exports[`only with expand arg 1`] = ` ✓ test describe ✓ test - -" `; exports[`only with expand arg 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 skipped, 7 passed, 8 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`skips 1`] = ` -"PASS __tests__/skipsConstructs.test.js +PASS __tests__/skipsConstructs.test.js ✓ it ○ skipped 4 tests xdescribe @@ -174,20 +157,18 @@ exports[`skips 1`] = ` ○ skipped 1 test describe ○ skipped 1 test - -" `; exports[`skips 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 8 skipped, 1 passed, 9 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`skips with expand arg 1`] = ` -"PASS __tests__/skipsConstructs.test.js +PASS __tests__/skipsConstructs.test.js ✓ it ○ xtest ○ xit @@ -200,14 +181,12 @@ exports[`skips with expand arg 1`] = ` ○ test describe ○ test - -" `; exports[`skips with expand arg 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 8 skipped, 1 passed, 9 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/__snapshots__/jest.config.js.test.js.snap b/e2e/__tests__/__snapshots__/jest.config.js.test.js.snap index d7080456d7bc..a49fd8ccbbc3 100644 --- a/e2e/__tests__/__snapshots__/jest.config.js.test.js.snap +++ b/e2e/__tests__/__snapshots__/jest.config.js.test.js.snap @@ -1,38 +1,34 @@ // 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:4 <>/jest.config.js/some/nested/directory -" + `; exports[`traverses directory tree up until it finds jest.config 2`] = ` -"PASS ../../../__tests__/a-banana.js +PASS ../../../__tests__/a-banana.js ✓ banana ✓ abc - -" `; exports[`traverses directory tree up until it finds jest.config 3`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`works with jest.config.js 1`] = ` -"PASS __tests__/a-banana.js +PASS __tests__/a-banana.js ✓ banana - -" `; exports[`works with jest.config.js 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/__snapshots__/jestChangedFiles.test.js.snap b/e2e/__tests__/__snapshots__/jestChangedFiles.test.js.snap index 61d5013154f9..52436014c7ec 100644 --- a/e2e/__tests__/__snapshots__/jestChangedFiles.test.js.snap +++ b/e2e/__tests__/__snapshots__/jestChangedFiles.test.js.snap @@ -1,21 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`handles a bad revision for "changedSince", for git 1`] = ` -" + ● Test suite failed to run fatal: bad revision '^blablabla' -" + `; exports[`handles a bad revision for "changedSince", for hg 1`] = ` -" + ● Test suite failed to run abort: unknown revision 'blablabla'! -" + `; diff --git a/e2e/__tests__/__snapshots__/listTests.test.js.snap b/e2e/__tests__/__snapshots__/listTests.test.js.snap index b1d8584f771e..3c12f33eab07 100644 --- a/e2e/__tests__/__snapshots__/listTests.test.js.snap +++ b/e2e/__tests__/__snapshots__/listTests.test.js.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`--listTests flag causes tests to be printed in different lines 1`] = ` -"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js -/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js" +/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js +/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js `; -exports[`--listTests flag causes tests to be printed out as JSON when using the --json flag 1`] = `"[\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js\\",\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js\\"]"`; +exports[`--listTests flag causes tests to be printed out as JSON when using the --json flag 1`] = `["/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js","/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js"]`; diff --git a/e2e/__tests__/__snapshots__/moduleNameMapper.test.js.snap b/e2e/__tests__/__snapshots__/moduleNameMapper.test.js.snap index 7f5aba3ac6de..812baf215ae5 100644 --- a/e2e/__tests__/__snapshots__/moduleNameMapper.test.js.snap +++ b/e2e/__tests__/__snapshots__/moduleNameMapper.test.js.snap @@ -1,14 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`moduleNameMapper correct configuration 1`] = ` -"PASS __tests__/index.js +PASS __tests__/index.js ✓ moduleNameMapping correct configuration - -" `; exports[`moduleNameMapper wrong configuration 1`] = ` -"FAIL __tests__/index.js +FAIL __tests__/index.js ● Test suite failed to run Configuration error: @@ -18,10 +16,10 @@ exports[`moduleNameMapper wrong configuration 1`] = ` Please check your configuration for these entries: { - \\"moduleNameMapper\\": { - \\"/\\\\.(css|less)$/\\": \\"no-such-module\\" + "moduleNameMapper": { + "/\\.(css|less)$/": "no-such-module" }, - \\"resolver\\": null + "resolver": null } 8 | 'use strict'; @@ -34,6 +32,4 @@ exports[`moduleNameMapper wrong configuration 1`] = ` at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:433:17) at Object.require (index.js:10:1) - -" `; diff --git a/e2e/__tests__/__snapshots__/multiProjectRunner.test.js.snap b/e2e/__tests__/__snapshots__/multiProjectRunner.test.js.snap index 98000bd2b809..43dc5c28220a 100644 --- a/e2e/__tests__/__snapshots__/multiProjectRunner.test.js.snap +++ b/e2e/__tests__/__snapshots__/multiProjectRunner.test.js.snap @@ -1,38 +1,37 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`can pass projects or global config 1`] = ` -"Test Suites: 3 failed, 3 total +Test Suites: 3 failed, 3 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites. -" `; exports[`can pass projects or global config 2`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 3 passed, 3 total Snapshots: 0 total Time: <> -Ran all test suites in 3 projects." +Ran all test suites in 3 projects. `; exports[`can pass projects or global config 3`] = ` -"PASS BACKEND project1/__tests__/file1.test.js +PASS BACKEND project1/__tests__/file1.test.js PASS UI project3/__tests__/file1.test.js -PASS project2/__tests__/file1.test.js" +PASS project2/__tests__/file1.test.js `; exports[`can pass projects or global config 4`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 3 passed, 3 total Snapshots: 0 total Time: <> -Ran all test suites in 3 projects." +Ran all test suites in 3 projects. `; exports[`can pass projects or global config 5`] = ` -"PASS BACKEND project1/__tests__/file1.test.js +PASS BACKEND project1/__tests__/file1.test.js PASS UI project3/__tests__/file1.test.js -PASS project2/__tests__/file1.test.js" +PASS project2/__tests__/file1.test.js `; diff --git a/e2e/__tests__/__snapshots__/processExit.test.js.snap b/e2e/__tests__/__snapshots__/processExit.test.js.snap index fbf88d8a68c4..13915892b8dc 100644 --- a/e2e/__tests__/__snapshots__/processExit.test.js.snap +++ b/e2e/__tests__/__snapshots__/processExit.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`prints stack trace pointing to process.exit call 1`] = ` -" ● process.exit called with \\"1\\" + ● process.exit called with "1" 1 | // Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | @@ -12,5 +12,5 @@ exports[`prints stack trace pointing to process.exit call 1`] = ` 6 | expect(true).toBe(true); at Object.exit (__tests__/test.js:3:9) -" + `; diff --git a/e2e/__tests__/__snapshots__/requireAfterTeardown.test.js.snap b/e2e/__tests__/__snapshots__/requireAfterTeardown.test.js.snap index 9817dc2361e1..31790c844a8d 100644 --- a/e2e/__tests__/__snapshots__/requireAfterTeardown.test.js.snap +++ b/e2e/__tests__/__snapshots__/requireAfterTeardown.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`prints useful error for requires after test is done 1`] = ` -"ReferenceError: You are trying to \`import\` a file after the Jest environment has been torn down. +ReferenceError: You are trying to \`import\` a file after the Jest environment has been torn down. 9 | test('require after done', () => { 10 | setTimeout(() => { @@ -9,5 +9,5 @@ exports[`prints useful error for requires after test is done 1`] = ` | ^ 12 | 13 | expect(double(5)).toBe(10); - 14 | }, 0);" + 14 | }, 0); `; diff --git a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.js.snap b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.js.snap index 17b7fc306b26..b05ff4df33c5 100644 --- a/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.js.snap +++ b/e2e/__tests__/__snapshots__/resolveNoFileExtensions.test.js.snap @@ -1,21 +1,21 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`show error message when no js moduleFileExtensions 1`] = ` -"● Validation Error: +● Validation Error: moduleFileExtensions must include 'js': but instead received: - [\\"jsx\\"] + ["jsx"] Please change your configuration to include 'js'. Configuration Documentation: https://jestjs.io/docs/configuration.html -" + `; exports[`show error message with matching files 1`] = ` -"FAIL __tests__/test.js +FAIL __tests__/test.js ● Test suite failed to run Cannot find module './some-json-file' from 'index.js' @@ -35,6 +35,4 @@ exports[`show error message with matching files 1`] = ` at Resolver.resolveModule (../../packages/jest-resolve/build/index.js:200:17) at Object.require (index.js:3:18) - -" `; diff --git a/e2e/__tests__/__snapshots__/showConfig.test.js.snap b/e2e/__tests__/__snapshots__/showConfig.test.js.snap index b7b8f2690bce..3814b86cfbc4 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.js.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.js.snap @@ -1,125 +1,125 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`--showConfig outputs config info and exits 1`] = ` -"{ - \\"configs\\": [ +{ + "configs": [ { - \\"automock\\": false, - \\"browser\\": false, - \\"cache\\": false, - \\"cacheDirectory\\": \\"/tmp/jest\\", - \\"clearMocks\\": false, - \\"coveragePathIgnorePatterns\\": [ - \\"/node_modules/\\" + "automock": false, + "browser": false, + "cache": false, + "cacheDirectory": "/tmp/jest", + "clearMocks": false, + "coveragePathIgnorePatterns": [ + "/node_modules/" ], - \\"cwd\\": \\"<>\\", - \\"dependencyExtractor\\": null, - \\"detectLeaks\\": false, - \\"detectOpenHandles\\": false, - \\"errorOnDeprecated\\": false, - \\"filter\\": null, - \\"forceCoverageMatch\\": [], - \\"globalSetup\\": null, - \\"globalTeardown\\": null, - \\"globals\\": {}, - \\"haste\\": { - \\"computeSha1\\": false, - \\"providesModuleNodeModules\\": [] + "cwd": "<>", + "dependencyExtractor": null, + "detectLeaks": false, + "detectOpenHandles": false, + "errorOnDeprecated": false, + "filter": null, + "forceCoverageMatch": [], + "globalSetup": null, + "globalTeardown": null, + "globals": {}, + "haste": { + "computeSha1": false, + "providesModuleNodeModules": [] }, - \\"moduleDirectories\\": [ - \\"node_modules\\" + "moduleDirectories": [ + "node_modules" ], - \\"moduleFileExtensions\\": [ - \\"js\\", - \\"json\\", - \\"jsx\\", - \\"ts\\", - \\"tsx\\", - \\"node\\" + "moduleFileExtensions": [ + "js", + "json", + "jsx", + "ts", + "tsx", + "node" ], - \\"moduleNameMapper\\": {}, - \\"modulePathIgnorePatterns\\": [], - \\"name\\": \\"[md5 hash]\\", - \\"prettierPath\\": \\"prettier\\", - \\"resetMocks\\": false, - \\"resetModules\\": false, - \\"resolver\\": null, - \\"restoreMocks\\": false, - \\"rootDir\\": \\"<>\\", - \\"roots\\": [ - \\"<>\\" + "moduleNameMapper": {}, + "modulePathIgnorePatterns": [], + "name": "[md5 hash]", + "prettierPath": "prettier", + "resetMocks": false, + "resetModules": false, + "resolver": null, + "restoreMocks": false, + "rootDir": "<>", + "roots": [ + "<>" ], - \\"runner\\": \\"jest-runner\\", - \\"setupFiles\\": [], - \\"setupFilesAfterEnv\\": [], - \\"skipFilter\\": false, - \\"snapshotSerializers\\": [], - \\"testEnvironment\\": \\"<>/jest-environment-jsdom/build/index.js\\", - \\"testEnvironmentOptions\\": {}, - \\"testLocationInResults\\": false, - \\"testMatch\\": [ - \\"**/__tests__/**/*.[jt]s?(x)\\", - \\"**/?(*.)+(spec|test).[tj]s?(x)\\" + "runner": "jest-runner", + "setupFiles": [], + "setupFilesAfterEnv": [], + "skipFilter": false, + "snapshotSerializers": [], + "testEnvironment": "<>/jest-environment-jsdom/build/index.js", + "testEnvironmentOptions": {}, + "testLocationInResults": false, + "testMatch": [ + "**/__tests__/**/*.[jt]s?(x)", + "**/?(*.)+(spec|test).[tj]s?(x)" ], - \\"testPathIgnorePatterns\\": [ - \\"/node_modules/\\" + "testPathIgnorePatterns": [ + "/node_modules/" ], - \\"testRegex\\": [], - \\"testRunner\\": \\"<>/jest-jasmine2/build/index.js\\", - \\"testURL\\": \\"http://localhost\\", - \\"timers\\": \\"real\\", - \\"transform\\": [ + "testRegex": [], + "testRunner": "<>/jest-jasmine2/build/index.js", + "testURL": "http://localhost", + "timers": "real", + "transform": [ [ - \\"^.+\\\\\\\\.[jt]sx?$\\", - \\"<>/babel-jest/build/index.js\\" + "^.+\\\\.[jt]sx?$", + "<>/babel-jest/build/index.js" ] ], - \\"transformIgnorePatterns\\": [ - \\"/node_modules/\\" + "transformIgnorePatterns": [ + "/node_modules/" ], - \\"watchPathIgnorePatterns\\": [] + "watchPathIgnorePatterns": [] } ], - \\"globalConfig\\": { - \\"bail\\": 0, - \\"changedFilesWithAncestor\\": false, - \\"collectCoverage\\": false, - \\"collectCoverageFrom\\": null, - \\"coverageDirectory\\": \\"<>/coverage\\", - \\"coverageReporters\\": [ - \\"json\\", - \\"text\\", - \\"lcov\\", - \\"clover\\" + "globalConfig": { + "bail": 0, + "changedFilesWithAncestor": false, + "collectCoverage": false, + "collectCoverageFrom": null, + "coverageDirectory": "<>/coverage", + "coverageReporters": [ + "json", + "text", + "lcov", + "clover" ], - \\"coverageThreshold\\": null, - \\"detectLeaks\\": false, - \\"detectOpenHandles\\": false, - \\"errorOnDeprecated\\": false, - \\"expand\\": false, - \\"filter\\": null, - \\"globalSetup\\": null, - \\"globalTeardown\\": null, - \\"listTests\\": false, - \\"maxWorkers\\": \\"[maxWorkers]\\", - \\"noStackTrace\\": false, - \\"nonFlagArgs\\": [], - \\"notify\\": false, - \\"notifyMode\\": \\"failure-change\\", - \\"passWithNoTests\\": false, - \\"projects\\": null, - \\"rootDir\\": \\"<>\\", - \\"runTestsByPath\\": false, - \\"skipFilter\\": false, - \\"testFailureExitCode\\": 1, - \\"testPathPattern\\": \\"\\", - \\"testResultsProcessor\\": null, - \\"updateSnapshot\\": \\"all\\", - \\"useStderr\\": false, - \\"verbose\\": null, - \\"watch\\": false, - \\"watchman\\": true + "coverageThreshold": null, + "detectLeaks": false, + "detectOpenHandles": false, + "errorOnDeprecated": false, + "expand": false, + "filter": null, + "globalSetup": null, + "globalTeardown": null, + "listTests": false, + "maxWorkers": "[maxWorkers]", + "noStackTrace": false, + "nonFlagArgs": [], + "notify": false, + "notifyMode": "failure-change", + "passWithNoTests": false, + "projects": null, + "rootDir": "<>", + "runTestsByPath": false, + "skipFilter": false, + "testFailureExitCode": 1, + "testPathPattern": "", + "testResultsProcessor": null, + "updateSnapshot": "all", + "useStderr": false, + "verbose": null, + "watch": false, + "watchman": true }, - \\"version\\": \\"[version]\\" -}" + "version": "[version]" +} `; diff --git a/e2e/__tests__/__snapshots__/snapshot.test.js.snap b/e2e/__tests__/__snapshots__/snapshot.test.js.snap index 4affd8faa05e..cf4fb4518a1a 100644 --- a/e2e/__tests__/__snapshots__/snapshot.test.js.snap +++ b/e2e/__tests__/__snapshots__/snapshot.test.js.snap @@ -1,138 +1,137 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Snapshot Validation deletes a snapshot when a test does removes all the snapshots 1`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 9 written, 9 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation deletes a snapshot when a test does removes all the snapshots 2`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 6 passed, 6 total Snapshots: 1 file removed, 5 passed, 5 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation deletes the snapshot if the test suite has been removed 1`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 9 written, 9 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation deletes the snapshot if the test suite has been removed 2`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 5 passed, 5 total Snapshots: 1 file removed, 5 passed, 5 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation does not save snapshots in CI mode by default 1`] = ` -"Test Suites: 3 failed, 3 total +Test Suites: 3 failed, 3 total Tests: 7 failed, 2 passed, 9 total Snapshots: 9 failed, 9 total Time: <> Ran all test suites. -" `; exports[`Snapshot Validation updates the snapshot when a test removes some snapshots 1`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 9 written, 9 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation updates the snapshot when a test removes some snapshots 2`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 1 removed, 1 updated, 7 passed, 8 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation works on subsequent runs without \`-u\` 1`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 9 written, 9 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot Validation works on subsequent runs without \`-u\` 2`] = ` -"Test Suites: 3 passed, 3 total +Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshots: 9 passed, 9 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot stores new snapshots on the first run 1`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 5 passed, 5 total Snapshots: 5 written, 5 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`Snapshot works with escaped characters 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 written, 1 total Time: <> -Ran all test suites matching /snapshot.test.js/i." +Ran all test suites matching /snapshot.test.js/i. `; exports[`Snapshot works with escaped characters 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 1 written, 1 passed, 2 total Time: <> -Ran all test suites matching /snapshot.test.js/i." +Ran all test suites matching /snapshot.test.js/i. `; exports[`Snapshot works with escaped characters 3`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 2 passed, 2 total Time: <> -Ran all test suites matching /snapshot.test.js/i." +Ran all test suites matching /snapshot.test.js/i. `; exports[`Snapshot works with escaped regex 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 2 written, 2 total Time: <> -Ran all test suites matching /snapshotEscapeRegex.js/i." +Ran all test suites matching /snapshotEscapeRegex.js/i. `; exports[`Snapshot works with escaped regex 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 2 passed, 2 total Time: <> -Ran all test suites matching /snapshotEscapeRegex.js/i." +Ran all test suites matching /snapshotEscapeRegex.js/i. `; exports[`Snapshot works with template literal substitutions 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 written, 1 total Time: <> -Ran all test suites matching /snapshotEscapeSubstitution.test.js/i." +Ran all test suites matching /snapshotEscapeSubstitution.test.js/i. `; exports[`Snapshot works with template literal substitutions 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 passed, 1 total Time: <> -Ran all test suites matching /snapshotEscapeSubstitution.test.js/i." +Ran all test suites matching /snapshotEscapeSubstitution.test.js/i. `; diff --git a/e2e/__tests__/__snapshots__/snapshotMockFs.test.js.snap b/e2e/__tests__/__snapshots__/snapshotMockFs.test.js.snap index 0b187ca45889..b179fed14a23 100644 --- a/e2e/__tests__/__snapshots__/snapshotMockFs.test.js.snap +++ b/e2e/__tests__/__snapshots__/snapshotMockFs.test.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`store snapshot even if fs is mocked 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 written, 1 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/__snapshots__/stackTrace.test.js.snap b/e2e/__tests__/__snapshots__/stackTrace.test.js.snap index c6f41c5d4735..5727411db190 100644 --- a/e2e/__tests__/__snapshots__/stackTrace.test.js.snap +++ b/e2e/__tests__/__snapshots__/stackTrace.test.js.snap @@ -1,64 +1,57 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Stack Trace does not print a stack trace for errors when --noStackTrace is given 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 3 failed, 3 total Snapshots: 0 total Time: <> Ran all test suites matching /testError.test.js/i. -" `; exports[`Stack Trace does not print a stack trace for matching errors when --noStackTrace is given 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> Ran all test suites matching /stackTrace.test.js/i. -" `; exports[`Stack Trace does not print a stack trace for runtime errors when --noStackTrace is given 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites matching /runtimeError.test.js/i. -" `; exports[`Stack Trace prints a stack trace for errors 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 3 failed, 3 total Snapshots: 0 total Time: <> Ran all test suites matching /testError.test.js/i. -" `; exports[`Stack Trace prints a stack trace for errors without message in stack trace 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> Ran all test suites matching /stackTraceWithoutMessage.test.js/i. -" `; exports[`Stack Trace prints a stack trace for matching errors 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> Ran all test suites matching /stackTrace.test.js/i. -" `; exports[`Stack Trace prints a stack trace for runtime errors 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: <> Ran all test suites matching /runtimeError.test.js/i. -" `; diff --git a/e2e/__tests__/__snapshots__/testNamePattern.test.js.snap b/e2e/__tests__/__snapshots__/testNamePattern.test.js.snap index c82117066040..ecd6203ccb9c 100644 --- a/e2e/__tests__/__snapshots__/testNamePattern.test.js.snap +++ b/e2e/__tests__/__snapshots__/testNamePattern.test.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`testNamePattern 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 3 skipped, 2 passed, 5 total Snapshots: 0 total Time: <> -Ran all test suites with tests matching \\"should match\\"." +Ran all test suites with tests matching "should match". `; diff --git a/e2e/__tests__/__snapshots__/testNamePatternSkipped.test.js.snap b/e2e/__tests__/__snapshots__/testNamePatternSkipped.test.js.snap index 27d85d22ccb6..6e7747e519cb 100644 --- a/e2e/__tests__/__snapshots__/testNamePatternSkipped.test.js.snap +++ b/e2e/__tests__/__snapshots__/testNamePatternSkipped.test.js.snap @@ -1,9 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`testNamePattern skipped 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 skipped, 1 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites with tests matching \\"false\\"." +Ran all test suites with tests matching "false". `; diff --git a/e2e/__tests__/__snapshots__/testTodo.test.js.snap b/e2e/__tests__/__snapshots__/testTodo.test.js.snap index 504ca6f1b5f8..29e820705f40 100644 --- a/e2e/__tests__/__snapshots__/testTodo.test.js.snap +++ b/e2e/__tests__/__snapshots__/testTodo.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`shows error messages when called with invalid argument 1`] = ` -"FAIL __tests__/todoNonString.test.js +FAIL __tests__/todoNonString.test.js ● Test suite failed to run Todo must be called with only a description. @@ -13,12 +13,10 @@ exports[`shows error messages when called with invalid argument 1`] = ` 9 | at Object.todo (__tests__/todoNonString.test.js:8:4) - -" `; exports[`shows error messages when called with multiple arguments 1`] = ` -"FAIL __tests__/todoMultipleArgs.test.js +FAIL __tests__/todoMultipleArgs.test.js ● Test suite failed to run Todo must be called with only a description. @@ -30,12 +28,10 @@ exports[`shows error messages when called with multiple arguments 1`] = ` 9 | at Object.todo (__tests__/todoMultipleArgs.test.js:8:4) - -" `; exports[`shows error messages when called with no arguments 1`] = ` -"FAIL __tests__/todoNoArgs.test.js +FAIL __tests__/todoNoArgs.test.js ● Test suite failed to run Todo must be called with only a description. @@ -47,12 +43,10 @@ exports[`shows error messages when called with no arguments 1`] = ` 9 | at Object.todo (__tests__/todoNoArgs.test.js:8:4) - -" `; exports[`works with all statuses 1`] = ` -"FAIL __tests__/statuses.test.js +FAIL __tests__/statuses.test.js ✓ passes ✕ fails ○ skipped 1 test @@ -74,6 +68,4 @@ exports[`works with all statuses 1`] = ` 16 | it.skip('skips', () => { at Object.toBe (__tests__/statuses.test.js:13:14) - -" `; diff --git a/e2e/__tests__/__snapshots__/timeouts.test.js.snap b/e2e/__tests__/__snapshots__/timeouts.test.js.snap index a74c620e52db..19ed2b0400be 100644 --- a/e2e/__tests__/__snapshots__/timeouts.test.js.snap +++ b/e2e/__tests__/__snapshots__/timeouts.test.js.snap @@ -1,25 +1,22 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`does not exceed the timeout 1`] = ` -"PASS __tests__/a-banana.js +PASS __tests__/a-banana.js ✓ banana - -" `; exports[`does not exceed the timeout 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`exceeds the timeout 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; diff --git a/e2e/__tests__/__snapshots__/timeoutsLegacy.test.js.snap b/e2e/__tests__/__snapshots__/timeoutsLegacy.test.js.snap index 93626023f7a5..e6434396d6f1 100644 --- a/e2e/__tests__/__snapshots__/timeoutsLegacy.test.js.snap +++ b/e2e/__tests__/__snapshots__/timeoutsLegacy.test.js.snap @@ -1,33 +1,30 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`can read and write jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` -"PASS __tests__/a-banana.js +PASS __tests__/a-banana.js ✓ banana - -" `; exports[`does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`exceeds the timeout set using jasmine.DEFAULT_TIMEOUT_INTERVAL 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> Ran all test suites. -" `; diff --git a/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.js.snap b/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.js.snap index 83ea8f0c8ded..d1d8ef47911c 100644 --- a/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.js.snap +++ b/e2e/__tests__/__snapshots__/toMatchInlineSnapshot.test.js.snap @@ -1,148 +1,148 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`basic support: initial write 1`] = ` -"test('inline snapshots', () => +test('inline snapshots', () => expect({apple: 'original value'}).toMatchInlineSnapshot(\` Object { - \\"apple\\": \\"original value\\", + "apple": "original value", } \`)); -" + `; exports[`basic support: snapshot mismatch 1`] = ` -"test('inline snapshots', () => +test('inline snapshots', () => expect({apple: 'updated value'}).toMatchInlineSnapshot(\` Object { - \\"apple\\": \\"original value\\", + "apple": "original value", } \`)); -" + `; exports[`basic support: snapshot passed 1`] = ` -"test('inline snapshots', () => +test('inline snapshots', () => expect({apple: 'original value'}).toMatchInlineSnapshot(\` Object { - \\"apple\\": \\"original value\\", + "apple": "original value", } \`)); -" + `; exports[`basic support: snapshot updated 1`] = ` -"test('inline snapshots', () => +test('inline snapshots', () => expect({apple: 'updated value'}).toMatchInlineSnapshot(\` Object { - \\"apple\\": \\"updated value\\", + "apple": "updated value", } \`)); -" + `; exports[`handles property matchers: initial write 1`] = ` -"test('handles property matchers', () => { +test('handles property matchers', () => { expect({createdAt: new Date()}).toMatchInlineSnapshot( {createdAt: expect.any(Date)}, \` Object { - \\"createdAt\\": Any, + "createdAt": Any, } \` ); }); -" + `; exports[`handles property matchers: snapshot failed 1`] = ` -"test('handles property matchers', () => { - expect({createdAt: \\"string\\"}).toMatchInlineSnapshot( +test('handles property matchers', () => { + expect({createdAt: "string"}).toMatchInlineSnapshot( {createdAt: expect.any(Date)}, \` Object { - \\"createdAt\\": Any, + "createdAt": Any, } \` ); }); -" + `; exports[`handles property matchers: snapshot passed 1`] = ` -"test('handles property matchers', () => { +test('handles property matchers', () => { expect({createdAt: new Date()}).toMatchInlineSnapshot( {createdAt: expect.any(Date)}, \` Object { - \\"createdAt\\": Any, + "createdAt": Any, } \` ); }); -" + `; exports[`handles property matchers: snapshot updated 1`] = ` -"test('handles property matchers', () => { +test('handles property matchers', () => { expect({createdAt: 'string'}).toMatchInlineSnapshot( {createdAt: expect.any(String)}, \` Object { - \\"createdAt\\": Any, + "createdAt": Any, } \` ); }); -" + `; exports[`removes obsolete external snapshots: external snapshot cleaned 1`] = ` -"test('removes obsolete external snapshots', () => { - expect('1').toMatchInlineSnapshot(\`\\"1\\"\`); +test('removes obsolete external snapshots', () => { + expect('1').toMatchInlineSnapshot(\`"1"\`); }); -" + `; exports[`removes obsolete external snapshots: initial write 1`] = ` -" + test('removes obsolete external snapshots', () => { expect('1').toMatchSnapshot(); }); - " + `; exports[`removes obsolete external snapshots: inline snapshot written 1`] = ` -"test('removes obsolete external snapshots', () => { - expect('1').toMatchInlineSnapshot(\`\\"1\\"\`); +test('removes obsolete external snapshots', () => { + expect('1').toMatchInlineSnapshot(\`"1"\`); }); -" + `; exports[`supports async matchers 1`] = ` -"test('inline snapshots', async () => { +test('inline snapshots', async () => { expect(Promise.resolve('success')).resolves.toMatchInlineSnapshot( - \`\\"success\\"\` + \`"success"\` ); - expect(Promise.reject('fail')).rejects.toMatchInlineSnapshot(\`\\"fail\\"\`); + expect(Promise.reject('fail')).rejects.toMatchInlineSnapshot(\`"fail"\`); }); -" + `; exports[`supports async tests 1`] = ` -"test('inline snapshots', async () => { +test('inline snapshots', async () => { await 'next tick'; expect(42).toMatchInlineSnapshot(\`42\`); }); -" + `; exports[`writes snapshots with non-literals in expect(...) 1`] = ` -"it('works with inline snapshots', () => { +it('works with inline snapshots', () => { expect({a: 1}).toMatchInlineSnapshot(\` Object { - \\"a\\": 1, + "a": 1, } \`); }); -" + `; diff --git a/e2e/__tests__/__snapshots__/toThrowErrorMatchingInlineSnapshot.test.js.snap b/e2e/__tests__/__snapshots__/toThrowErrorMatchingInlineSnapshot.test.js.snap index 7bc6cb8fcb4b..eb1a037f29aa 100644 --- a/e2e/__tests__/__snapshots__/toThrowErrorMatchingInlineSnapshot.test.js.snap +++ b/e2e/__tests__/__snapshots__/toThrowErrorMatchingInlineSnapshot.test.js.snap @@ -1,28 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should support rejecting promises 1`] = ` -"test('should support rejecting promises', async () => { +test('should support rejecting promises', async () => { await expect( Promise.reject(new Error('octopus')) - ).rejects.toThrowErrorMatchingInlineSnapshot(\`\\"octopus\\"\`); + ).rejects.toThrowErrorMatchingInlineSnapshot(\`"octopus"\`); }); -" + `; exports[`updates existing snapshot: updated snapshot 1`] = ` -"test('updates existing snapshot', () => { +test('updates existing snapshot', () => { expect(() => { throw new Error('apple'); - }).toThrowErrorMatchingInlineSnapshot(\`\\"apple\\"\`); + }).toThrowErrorMatchingInlineSnapshot(\`"apple"\`); }); -" + `; exports[`works fine when function throws error: initial write 1`] = ` -"test('works fine when function throws error', () => { +test('works fine when function throws error', () => { expect(() => { throw new Error('apple'); - }).toThrowErrorMatchingInlineSnapshot(\`\\"apple\\"\`); + }).toThrowErrorMatchingInlineSnapshot(\`"apple"\`); }); -" + `; diff --git a/e2e/__tests__/__snapshots__/toThrowErrorMatchingSnapshot.test.js.snap b/e2e/__tests__/__snapshots__/toThrowErrorMatchingSnapshot.test.js.snap index 826e88eaf160..5cab09df743f 100644 --- a/e2e/__tests__/__snapshots__/toThrowErrorMatchingSnapshot.test.js.snap +++ b/e2e/__tests__/__snapshots__/toThrowErrorMatchingSnapshot.test.js.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should support rejecting promises 1`] = ` -"// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[\`should support rejecting promises 1\`] = \`"octopus"\`; -exports[\`should support rejecting promises 1\`] = \`\\"octopus\\"\`; -" `; diff --git a/e2e/__tests__/__snapshots__/transform.test.js.snap b/e2e/__tests__/__snapshots__/transform.test.js.snap index b6a57fc88c48..aad749c2f0ad 100644 --- a/e2e/__tests__/__snapshots__/transform.test.js.snap +++ b/e2e/__tests__/__snapshots__/transform.test.js.snap @@ -1,28 +1,28 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`babel-jest 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 | -------------|----------|----------|----------|----------|-------------------|" +------------|----------|----------|----------|----------|-------------------| `; exports[`custom transformer instruments files 1`] = ` -"----------|----------|----------|----------|----------|-------------------| +----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 0 | 0 | 0 | 0 | | -----------|----------|----------|----------|----------|-------------------|" +----------|----------|----------|----------|----------|-------------------| `; exports[`no babel-jest instrumentation with no babel-jest 1`] = ` -"------------|----------|----------|----------|----------|-------------------| +------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ------------|----------|----------|----------|----------|-------------------| All files | 83.33 | 100 | 50 | 80 | | covered.js | 83.33 | 100 | 50 | 80 | 13 | ------------|----------|----------|----------|----------|-------------------| -" + `; diff --git a/e2e/__tests__/__snapshots__/typescriptCoverage.test.js.snap b/e2e/__tests__/__snapshots__/typescriptCoverage.test.js.snap index 3f12fd48d96c..e3f422c49a17 100644 --- a/e2e/__tests__/__snapshots__/typescriptCoverage.test.js.snap +++ b/e2e/__tests__/__snapshots__/typescriptCoverage.test.js.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`instruments and collects coverage for typescript files 1`] = ` -"------------|----------|----------|----------|----------|-------------------| +------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ------------|----------|----------|----------|----------|-------------------| All files | 100 | 100 | 100 | 100 | | covered.ts | 100 | 100 | 100 | 100 | | -------------|----------|----------|----------|----------|-------------------|" +------------|----------|----------|----------|----------|-------------------| `; diff --git a/e2e/__tests__/__snapshots__/watchModeOnlyFailed.test.js.snap b/e2e/__tests__/__snapshots__/watchModeOnlyFailed.test.js.snap index 7043b221965f..6d8293f99e62 100644 --- a/e2e/__tests__/__snapshots__/watchModeOnlyFailed.test.js.snap +++ b/e2e/__tests__/__snapshots__/watchModeOnlyFailed.test.js.snap @@ -1,47 +1,47 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`can press "f" to run only failed tests: test results 1`] = ` -"FAIL __tests__/bar.spec.js +FAIL __tests__/bar.spec.js ● bar 1 expect(received).toBe(expected) // Object.is equality - Expected: \\"foo\\" - Received: \\"bar\\" + Expected: "foo" + Received: "bar" 1 | > 2 | test('bar 1', () => { expect('bar').toBe('foo'); }); | ^ 3 | at Object.toBe (__tests__/bar.spec.js:2:43) -PASS __tests__/foo.spec.js" +PASS __tests__/foo.spec.js `; exports[`can press "f" to run only failed tests: test results 2`] = ` -"FAIL __tests__/bar.spec.js +FAIL __tests__/bar.spec.js ✕ bar 1 ● bar 1 expect(received).toBe(expected) // Object.is equality - Expected: \\"foo\\" - Received: \\"bar\\" + Expected: "foo" + Received: "bar" 1 | > 2 | test('bar 1', () => { expect('bar').toBe('foo'); }); | ^ 3 | at Object.toBe (__tests__/bar.spec.js:2:43) -" + `; exports[`can press "f" to run only failed tests: test summary 1`] = ` -"Test Suites: 1 failed, 1 passed, 2 total +Test Suites: 1 failed, 1 passed, 2 total Tests: 1 failed, 1 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`can press "f" to run only failed tests: test summary 2`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/__snapshots__/watchModePatterns.test.js.snap b/e2e/__tests__/__snapshots__/watchModePatterns.test.js.snap index 1377c1d3890b..f6764504118d 100644 --- a/e2e/__tests__/__snapshots__/watchModePatterns.test.js.snap +++ b/e2e/__tests__/__snapshots__/watchModePatterns.test.js.snap @@ -16,31 +16,31 @@ Pattern Mode Usage `; exports[`can press "p" to filter by file name: test results 1`] = ` -"PASS __tests__/bar.spec.js -PASS __tests__/foo.spec.js" +PASS __tests__/bar.spec.js +PASS __tests__/foo.spec.js `; exports[`can press "p" to filter by file name: test results 2`] = ` -"PASS __tests__/bar.spec.js +PASS __tests__/bar.spec.js ✓ bar 1 ✓ bar 2 -" + `; exports[`can press "p" to filter by file name: test summary 1`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 4 passed, 4 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`can press "p" to filter by file name: test summary 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 0 total Time: <> -Ran all test suites matching /bar/i." +Ran all test suites matching /bar/i. `; exports[`can press "t" to filter by test name 1`] = ` @@ -57,27 +57,27 @@ Pattern Mode Usage `; exports[`can press "t" to filter by test name: test results 1`] = ` -"PASS __tests__/bar.spec.js -PASS __tests__/foo.spec.js" +PASS __tests__/bar.spec.js +PASS __tests__/foo.spec.js `; exports[`can press "t" to filter by test name: test results 2`] = ` -"PASS __tests__/bar.spec.js -PASS __tests__/foo.spec.js" +PASS __tests__/bar.spec.js +PASS __tests__/foo.spec.js `; exports[`can press "t" to filter by test name: test summary 1`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 4 passed, 4 total Snapshots: 0 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`can press "t" to filter by test name: test summary 2`] = ` -"Test Suites: 2 passed, 2 total +Test Suites: 2 passed, 2 total Tests: 2 skipped, 2 passed, 4 total Snapshots: 0 total Time: <> -Ran all test suites with tests matching \\"2\\"." +Ran all test suites with tests matching "2". `; diff --git a/e2e/__tests__/__snapshots__/watchModeUpdateSnapshot.test.js.snap b/e2e/__tests__/__snapshots__/watchModeUpdateSnapshot.test.js.snap index 1638a29e5a4e..7023c87719c2 100644 --- a/e2e/__tests__/__snapshots__/watchModeUpdateSnapshot.test.js.snap +++ b/e2e/__tests__/__snapshots__/watchModeUpdateSnapshot.test.js.snap @@ -1,15 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`can press "u" to update snapshots: test results 1`] = ` -"FAIL __tests__/bar.spec.js +FAIL __tests__/bar.spec.js ✕ bar ● bar expect(value).toMatchSnapshot() - Received value does not match stored snapshot \\"bar 1\\". + Received value does not match stored snapshot "bar 1". - Snapshot + Received - - \\"foo\\" - + \\"bar\\" + - "foo" + + "bar" 1 | > 2 | test('bar', () => { expect('bar').toMatchSnapshot(); }); | ^ @@ -18,30 +18,30 @@ exports[`can press "u" to update snapshots: test results 1`] = ` › 1 snapshot failed. Snapshot Summary › 1 snapshot failed from 1 test suite. Inspect your code changes or press \`u\` to update them. -" + `; exports[`can press "u" to update snapshots: test results 2`] = ` -"PASS __tests__/bar.spec.js +PASS __tests__/bar.spec.js ✓ bar › 1 snapshot updated. Snapshot Summary › 1 snapshot updated from 1 test suite. -" + `; exports[`can press "u" to update snapshots: test summary 1`] = ` -"Test Suites: 1 failed, 1 total +Test Suites: 1 failed, 1 total Tests: 1 failed, 1 total Snapshots: 1 failed, 1 total Time: <> -Ran all test suites." +Ran all test suites. `; exports[`can press "u" to update snapshots: test summary 2`] = ` -"Test Suites: 1 passed, 1 total +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 updated, 1 total Time: <> -Ran all test suites." +Ran all test suites. `; diff --git a/e2e/__tests__/autoClearMocks.test.js b/e2e/__tests__/autoClearMocks.test.js index 0a8d690855dd..1b352e1d1943 100644 --- a/e2e/__tests__/autoClearMocks.test.js +++ b/e2e/__tests__/autoClearMocks.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/autoResetMocks.test.js b/e2e/__tests__/autoResetMocks.test.js index b54acf7259ec..01346d698908 100644 --- a/e2e/__tests__/autoResetMocks.test.js +++ b/e2e/__tests__/autoResetMocks.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/autoRestoreMocks.test.js b/e2e/__tests__/autoRestoreMocks.test.js index aaea26cde250..7f2366d5282a 100644 --- a/e2e/__tests__/autoRestoreMocks.test.js +++ b/e2e/__tests__/autoRestoreMocks.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/babelPluginJestHoist.test.js b/e2e/__tests__/babelPluginJestHoist.test.js index 70062d2eb6c5..6820262f5960 100644 --- a/e2e/__tests__/babelPluginJestHoist.test.js +++ b/e2e/__tests__/babelPluginJestHoist.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import path from 'path'; import {json as runWithJson} from '../runJest'; diff --git a/e2e/__tests__/badSourceMap.test.js b/e2e/__tests__/badSourceMap.test.js index d6a02abfc187..471703726e60 100644 --- a/e2e/__tests__/badSourceMap.test.js +++ b/e2e/__tests__/badSourceMap.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/beforeAllFiltered.js b/e2e/__tests__/beforeAllFiltered.js index 4c1746e53fe0..a930d148ecfd 100644 --- a/e2e/__tests__/beforeAllFiltered.js +++ b/e2e/__tests__/beforeAllFiltered.js @@ -6,13 +6,13 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; describe('Correct BeforeAll run', () => { it('ensures the BeforeAll of ignored suite is not run', () => { const result = runJest('before-all-filtered'); - expect(result.stdout.replace(/\\/g, '/')).toMatchSnapshot(); + expect(wrap(result.stdout.replace(/\\/g, '/'))).toMatchSnapshot(); }); }); diff --git a/e2e/__tests__/beforeEachQueue.js b/e2e/__tests__/beforeEachQueue.js index dc2104968f20..24ff77c3459f 100644 --- a/e2e/__tests__/beforeEachQueue.js +++ b/e2e/__tests__/beforeEachQueue.js @@ -6,13 +6,13 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; describe('Correct beforeEach order', () => { it('ensures the correct order for beforeEach', () => { const result = runJest('before-each-queue'); - expect(result.stdout.replace(/\\/g, '/')).toMatchSnapshot(); + expect(wrap(result.stdout.replace(/\\/g, '/'))).toMatchSnapshot(); }); }); diff --git a/e2e/__tests__/clearCache.test.js b/e2e/__tests__/clearCache.test.js index 27e10dff4ac8..96e6d3207aa1 100644 --- a/e2e/__tests__/clearCache.test.js +++ b/e2e/__tests__/clearCache.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import fs from 'fs'; import os from 'os'; diff --git a/e2e/__tests__/cliHandlesExactFilenames.test.js b/e2e/__tests__/cliHandlesExactFilenames.test.js index 407dcbe57ffe..263a012eec9e 100644 --- a/e2e/__tests__/cliHandlesExactFilenames.test.js +++ b/e2e/__tests__/cliHandlesExactFilenames.test.js @@ -7,12 +7,11 @@ * @flow */ -'use strict'; - import path from 'path'; import {skipSuiteOnWindows} from '../../scripts/ConditionalTest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../cli_accepts_exact_filenames'); @@ -35,9 +34,9 @@ test('CLI accepts exact file names if matchers matched', () => { const {rest, summary} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(result.stdout).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(result.stdout).toBe(''); }); test('CLI skips exact file names if no matchers matched', () => { diff --git a/e2e/__tests__/compareDomNodes.test.js b/e2e/__tests__/compareDomNodes.test.js index e17e0d0d578f..91bde64e2b2e 100644 --- a/e2e/__tests__/compareDomNodes.test.js +++ b/e2e/__tests__/compareDomNodes.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/config.test.js b/e2e/__tests__/config.test.js index 33d37caa4f32..f0be7331981a 100644 --- a/e2e/__tests__/config.test.js +++ b/e2e/__tests__/config.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/console.test.js b/e2e/__tests__/console.test.js index b3a1b02138b3..214566f9c894 100644 --- a/e2e/__tests__/console.test.js +++ b/e2e/__tests__/console.test.js @@ -7,18 +7,17 @@ * @flow */ -'use strict'; - import {extractSummary} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('console printing', () => { const {stderr, status} = runJest('console'); const {summary, rest} = extractSummary(stderr); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('console printing with --verbose', () => { @@ -29,9 +28,9 @@ test('console printing with --verbose', () => { const {summary, rest} = extractSummary(stderr); expect(status).toBe(0); - expect(stdout).toMatchSnapshot(); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('does not print to console with --silent', () => { @@ -47,9 +46,9 @@ test('does not print to console with --silent', () => { const {summary, rest} = extractSummary(stderr); expect(status).toBe(0); - expect(stdout).toMatchSnapshot(); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); // issue: https://github.com/facebook/jest/issues/5223 @@ -58,7 +57,7 @@ test('the jsdom console is the same as the test console', () => { const {summary, rest} = extractSummary(stderr); expect(status).toBe(0); - expect(stdout).toMatchSnapshot(); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/consoleLogOutputWhenRunInBand.test.js b/e2e/__tests__/consoleLogOutputWhenRunInBand.test.js index 5f4412f68bbf..3e2c04233607 100644 --- a/e2e/__tests__/consoleLogOutputWhenRunInBand.test.js +++ b/e2e/__tests__/consoleLogOutputWhenRunInBand.test.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../console-log-output-when-run-in-band'); @@ -33,7 +32,7 @@ test('prints console.logs when run with forceExit', () => { ]); const {rest, summary} = extractSummary(stderr); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(stdout).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/coverageRemapping.test.js b/e2e/__tests__/coverageRemapping.test.js index 5f1986890553..12d83544ff72 100644 --- a/e2e/__tests__/coverageRemapping.test.js +++ b/e2e/__tests__/coverageRemapping.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import {readFileSync} from 'fs'; import path from 'path'; import {cleanup, run} from '../Utils'; diff --git a/e2e/__tests__/coverageReport.test.js b/e2e/__tests__/coverageReport.test.js index 9fab19fb0670..b17fd88e85e4 100644 --- a/e2e/__tests__/coverageReport.test.js +++ b/e2e/__tests__/coverageReport.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; import {extractSummary} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../coverage-report'); @@ -26,7 +26,7 @@ test('outputs coverage report', () => { // is listed with 0 % coverage. // - `notRequiredInTestSuite.js` is not required but it is listed // with 0 % coverage. - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(() => fs.accessSync(coverageDir, fs.F_OK)).not.toThrow(); expect(status).toBe(0); @@ -45,7 +45,7 @@ test('collects coverage only from specified file', () => { ); // Coverage report should only have `setup.js` coverage info - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('collects coverage only from multiple specified files', () => { @@ -62,7 +62,7 @@ test('collects coverage only from multiple specified files', () => { {stripAnsi: true}, ); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('collects coverage only from specified files avoiding dependencies', () => { @@ -80,7 +80,7 @@ test('collects coverage only from specified files avoiding dependencies', () => ); // Coverage report should only have `sum.js` coverage info - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('json reporter printing with --coverage', () => { @@ -89,7 +89,7 @@ test('json reporter printing with --coverage', () => { }); const {summary} = extractSummary(stderr); expect(status).toBe(1); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('outputs coverage report as json', () => { @@ -115,7 +115,7 @@ test('outputs coverage report when text is requested', () => { ); expect(status).toBe(0); expect(stdout).toMatch(/Stmts | . Branch/); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('outputs coverage report when text-summary is requested', () => { @@ -126,7 +126,7 @@ test('outputs coverage report when text-summary is requested', () => { ); expect(status).toBe(0); expect(stdout).toMatch(/Coverage summary/); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('outputs coverage report when text and text-summary is requested', () => { @@ -143,7 +143,7 @@ test('outputs coverage report when text and text-summary is requested', () => { expect(status).toBe(0); expect(stdout).toMatch(/Stmts | . Branch/); expect(stdout).toMatch(/Coverage summary/); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('does not output coverage report when html is requested', () => { @@ -154,7 +154,7 @@ test('does not output coverage report when html is requested', () => { ); expect(status).toBe(0); expect(stdout).toMatch(/^$/); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('collects coverage from duplicate files avoiding shared cache', () => { @@ -175,7 +175,7 @@ test('collects coverage from duplicate files avoiding shared cache', () => { // Run for the second time const {stdout, status} = runJest(DIR, args, {stripAnsi: true}); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(status).toBe(0); }); @@ -185,6 +185,6 @@ test('generates coverage when using the testRegex config param ', () => { '--testRegex=__tests__', '--coverage', ]); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(status).toBe(0); }); diff --git a/e2e/__tests__/coverageThreshold.test.js b/e2e/__tests__/coverageThreshold.test.js index d655c88be4b0..d86abc100554 100644 --- a/e2e/__tests__/coverageThreshold.test.js +++ b/e2e/__tests__/coverageThreshold.test.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../coverage-threshold'); @@ -50,9 +49,9 @@ test('exits with 1 if coverage threshold is not met', () => { const {rest, summary} = extractSummary(stderr); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(stdout).toMatchSnapshot('stdout'); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot('stdout'); }); test('exits with 1 if path threshold group is not found in coverage data', () => { @@ -87,9 +86,9 @@ test('exits with 1 if path threshold group is not found in coverage data', () => const {rest, summary} = extractSummary(stderr); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(stdout).toMatchSnapshot('stdout'); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot('stdout'); }); test('exits with 0 if global threshold group is not found in coverage data', () => { @@ -126,7 +125,7 @@ test('exits with 0 if global threshold group is not found in coverage data', () }); expect(status).toBe(0); - expect(stdout).toMatchSnapshot('stdout'); + expect(wrap(stdout)).toMatchSnapshot('stdout'); }); test('excludes tests matched by path threshold groups from global group', () => { @@ -169,9 +168,9 @@ test('excludes tests matched by path threshold groups from global group', () => const {rest, summary} = extractSummary(stderr); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(stdout).toMatchSnapshot('stdout'); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot('stdout'); }); test('file is matched by all path and glob threshold groups', () => { @@ -219,7 +218,7 @@ test('file is matched by all path and glob threshold groups', () => { ); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); - expect(stdout).toMatchSnapshot('stdout'); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot('stdout'); }); diff --git a/e2e/__tests__/coverageTransformInstrumented.test.js b/e2e/__tests__/coverageTransformInstrumented.test.js index da8700e2a27d..0f7227ea7f4c 100644 --- a/e2e/__tests__/coverageTransformInstrumented.test.js +++ b/e2e/__tests__/coverageTransformInstrumented.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import {readFileSync} from 'fs'; import path from 'path'; import {cleanup, run} from '../Utils'; diff --git a/e2e/__tests__/customMatcherStackTrace.test.js b/e2e/__tests__/customMatcherStackTrace.test.js index 46d99eddea5c..c9b13df573e0 100644 --- a/e2e/__tests__/customMatcherStackTrace.test.js +++ b/e2e/__tests__/customMatcherStackTrace.test.js @@ -6,10 +6,10 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('works with custom matchers', () => { const {stderr} = runJest('custom-matcher-stack-trace'); @@ -21,5 +21,5 @@ test('works with custom matchers', () => { .filter(line => line.indexOf('at Error (native)') < 0) .join('\n'); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/customReporters.test.js b/e2e/__tests__/customReporters.test.js index 0fba6b615965..6669cc14a48b 100644 --- a/e2e/__tests__/customReporters.test.js +++ b/e2e/__tests__/customReporters.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; import os from 'os'; import path from 'path'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'custom-reporters-test-dir'); @@ -46,7 +46,7 @@ describe('Custom Reporters Integration', () => { 'add.test.js', ]); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(status).toBe(0); }); @@ -62,7 +62,7 @@ describe('Custom Reporters Integration', () => { ]); expect(status).toBe(1); - expect(stderr).toMatchSnapshot(); + expect(wrap(stderr)).toMatchSnapshot(); }); test('default reporters enabled', () => { @@ -78,8 +78,8 @@ describe('Custom Reporters Integration', () => { const parsedJSON = JSON.parse(stdout); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(parsedJSON).toMatchSnapshot(); }); @@ -120,7 +120,7 @@ describe('Custom Reporters Integration', () => { expect(status).toBe(0); expect(stderr).toBe(''); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('prints reporter errors', () => { diff --git a/e2e/__tests__/customResolver.test.js b/e2e/__tests__/customResolver.test.js index 895f259f0fa9..f0dac2f418a4 100644 --- a/e2e/__tests__/customResolver.test.js +++ b/e2e/__tests__/customResolver.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/deprecatedCliOptions.test.js b/e2e/__tests__/deprecatedCliOptions.test.js index 6f06b542c338..4c305750bf88 100644 --- a/e2e/__tests__/deprecatedCliOptions.test.js +++ b/e2e/__tests__/deprecatedCliOptions.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; diff --git a/e2e/__tests__/detectOpenHandles.js b/e2e/__tests__/detectOpenHandles.js index 2aa76243bca8..71e8a09bba99 100644 --- a/e2e/__tests__/detectOpenHandles.js +++ b/e2e/__tests__/detectOpenHandles.js @@ -6,9 +6,9 @@ * * @flow */ -'use strict'; import runJest, {until} from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; try { // $FlowFixMe: Node core @@ -36,7 +36,7 @@ it('prints message about flag on slow tests', async () => { ); const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toMatchSnapshot(); + expect(wrap(textAfterTest)).toMatchSnapshot(); }); it('prints message about flag on forceExit', async () => { @@ -47,7 +47,7 @@ it('prints message about flag on forceExit', async () => { ); const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toMatchSnapshot(); + expect(wrap(textAfterTest)).toMatchSnapshot(); }); it('prints out info about open handlers', async () => { @@ -58,7 +58,7 @@ it('prints out info about open handlers', async () => { ); const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toMatchSnapshot(); + expect(wrap(textAfterTest)).toMatchSnapshot(); }); it('does not report promises', () => { @@ -80,5 +80,5 @@ it('prints out info about open handlers from inside tests', async () => { ); const textAfterTest = getTextAfterTest(stderr); - expect(textAfterTest).toMatchSnapshot(); + expect(wrap(textAfterTest)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/each.test.js b/e2e/__tests__/each.test.js index f6ddda5d9ecd..27103512d246 100644 --- a/e2e/__tests__/each.test.js +++ b/e2e/__tests__/each.test.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const dir = path.resolve(__dirname, '../each'); @@ -24,7 +23,7 @@ test('shows error message when not enough arguments are supplied to tests', () = const result = runJest(dir, ['eachException.test.js']); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('shows the correct errors in stderr when failing tests', () => { @@ -34,33 +33,33 @@ test('shows the correct errors in stderr when failing tests', () => { .rest.split('\n') .map(line => line.trimRight()) .join('\n'); - expect(output).toMatchSnapshot(); + expect(wrap(output)).toMatchSnapshot(); }); test('shows only the tests with .only as being ran', () => { const result = runJest(dir, ['eachOnly.test.js']); expect(result.status).toBe(0); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('shows only the tests without .skip as being ran', () => { const result = runJest(dir, ['eachSkip.test.js']); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); expect(result.status).toBe(0); }); test('runs only the describe.only.each tests', () => { const result = runJest(dir, ['describeOnly.test.js']); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); expect(result.status).toBe(0); }); test('formats args with pretty format when given %p', () => { const result = runJest(dir, ['pretty.test.js']); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); expect(result.status).toBe(0); }); diff --git a/e2e/__tests__/emptyDescribeWithHooks.test.js b/e2e/__tests__/emptyDescribeWithHooks.test.js index a20c8e8c8a0e..a9620ecd7d36 100644 --- a/e2e/__tests__/emptyDescribeWithHooks.test.js +++ b/e2e/__tests__/emptyDescribeWithHooks.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; diff --git a/e2e/__tests__/env.test.js b/e2e/__tests__/env.test.js index 5a1f8f8835a0..2c2a36527c64 100644 --- a/e2e/__tests__/env.test.js +++ b/e2e/__tests__/env.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/errorOnDeprecated.test.js b/e2e/__tests__/errorOnDeprecated.test.js index b341dea25140..77807210b6e8 100644 --- a/e2e/__tests__/errorOnDeprecated.test.js +++ b/e2e/__tests__/errorOnDeprecated.test.js @@ -6,11 +6,11 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; import {skipSuiteOnJestCircus} from '../../scripts/ConditionalTest'; +import {wrap} from 'jest-snapshot-serializer-raw'; skipSuiteOnJestCircus(); @@ -42,7 +42,7 @@ testFiles.forEach(testFile => { ]); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); }); diff --git a/e2e/__tests__/executeTestsOnceInMpr.js b/e2e/__tests__/executeTestsOnceInMpr.js index 23f5e07a4396..1ee70319b9fb 100644 --- a/e2e/__tests__/executeTestsOnceInMpr.js +++ b/e2e/__tests__/executeTestsOnceInMpr.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../execute-tests-once-in-mpr'); @@ -58,6 +57,6 @@ test('Tests are executed only once even in an MPR', () => { // We have only one test passed, so total should equal to one, despite we have // three projects. - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); expect(summary).toMatch(/1 total/); }); diff --git a/e2e/__tests__/expectAsyncMatcher.test.js b/e2e/__tests__/expectAsyncMatcher.test.js index e4e78b82d67b..f6e91e911e42 100644 --- a/e2e/__tests__/expectAsyncMatcher.test.js +++ b/e2e/__tests__/expectAsyncMatcher.test.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const dir = path.resolve(__dirname, '../expect-async-matcher'); test('works with passing tests', () => { @@ -29,5 +28,5 @@ test('shows the correct errors in stderr when failing tests', () => { .filter(line => line.indexOf('packages/expect/build/index.js') === -1) .join('\n'); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/expectInVm.test.js b/e2e/__tests__/expectInVm.test.js index 7e27314a2320..380b9ac5d868 100644 --- a/e2e/__tests__/expectInVm.test.js +++ b/e2e/__tests__/expectInVm.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; test('expect works correctly with RegExps created inside a VM', () => { diff --git a/e2e/__tests__/failures.test.js b/e2e/__tests__/failures.test.js index 088248ca76fb..a47e42452539 100644 --- a/e2e/__tests__/failures.test.js +++ b/e2e/__tests__/failures.test.js @@ -10,6 +10,7 @@ import path from 'path'; import {extractSummary} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const dir = path.resolve(__dirname, '../failures'); @@ -25,15 +26,15 @@ function cleanStderr(stderr) { test('not throwing Error objects', () => { let stderr; stderr = runJest(dir, ['throwNumber.test.js']).stderr; - expect(cleanStderr(stderr)).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['throwString.test.js']).stderr; - expect(cleanStderr(stderr)).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['throwObject.test.js']).stderr; - expect(cleanStderr(stderr)).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['assertionCount.test.js']).stderr; - expect(cleanStderr(stderr)).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); stderr = runJest(dir, ['duringTests.test.js']).stderr; - expect(cleanStderr(stderr)).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); }); test('works with node assert', () => { @@ -138,13 +139,13 @@ test('works with node assert', () => { summary = summary.replace(ifErrorMessage, ''); } - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('works with assertions in separate files', () => { const {stderr} = runJest(dir, ['testMacro.test.js']); - expect(normalizeDots(cleanStderr(stderr))).toMatchSnapshot(); + expect(wrap(normalizeDots(cleanStderr(stderr)))).toMatchSnapshot(); }); test('works with async failures', () => { @@ -161,7 +162,7 @@ test('works with async failures', () => { .replace(/.*Use jest\.setTimeout\(newTimeout\).*/, '') .replace(/.*Timeout - Async callback was not.*/, ''); - expect(result).toMatchSnapshot(); + expect(wrap(result)).toMatchSnapshot(); }); test('works with snapshot failures', () => { @@ -170,7 +171,7 @@ test('works with snapshot failures', () => { const result = normalizeDots(cleanStderr(stderr)); expect( - result.substring(0, result.indexOf('Snapshot Summary')), + wrap(result.substring(0, result.indexOf('Snapshot Summary'))), ).toMatchSnapshot(); }); @@ -180,6 +181,6 @@ test('works with named snapshot failures', () => { const result = normalizeDots(cleanStderr(stderr)); expect( - result.substring(0, result.indexOf('Snapshot Summary')), + wrap(result.substring(0, result.indexOf('Snapshot Summary'))), ).toMatchSnapshot(); }); diff --git a/e2e/__tests__/fakePromises.test.js b/e2e/__tests__/fakePromises.test.js index d946dff7202c..5533b87c7b90 100644 --- a/e2e/__tests__/fakePromises.test.js +++ b/e2e/__tests__/fakePromises.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/filter.test.js b/e2e/__tests__/filter.test.js index ab51ea2edf1d..54fe03bb8a2a 100644 --- a/e2e/__tests__/filter.test.js +++ b/e2e/__tests__/filter.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/findRelatedFiles.test.js b/e2e/__tests__/findRelatedFiles.test.js index e11fd98b984b..3017a3fa8e35 100644 --- a/e2e/__tests__/findRelatedFiles.test.js +++ b/e2e/__tests__/findRelatedFiles.test.js @@ -7,12 +7,11 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'find-related-tests-test'); @@ -120,17 +119,19 @@ describe('--findRelatedTests flag', () => { let summary; let rest; ({summary, rest} = extractSummary(stderr)); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect( - rest - .split('\n') - .map(s => s.trim()) - .sort() - .join('\n'), + wrap( + rest + .split('\n') + .map(s => s.trim()) + .sort() + .join('\n'), + ), ).toMatchSnapshot(); // both a.js and b.js should be in the coverage - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); ({stdout, stderr} = runJest(DIR, ['--findRelatedTests', 'a.js'], { stripAnsi: true, @@ -138,11 +139,11 @@ describe('--findRelatedTests flag', () => { ({summary, rest} = extractSummary(stderr)); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); // should only run a.js - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); // coverage should be collected only for a.js - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); test('coverage configuration is applied correctly', () => { @@ -170,17 +171,19 @@ describe('--findRelatedTests flag', () => { })); const {summary, rest} = extractSummary(stderr); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect( - rest - .split('\n') - .map(s => s.trim()) - .sort() - .join('\n'), + wrap( + rest + .split('\n') + .map(s => s.trim()) + .sort() + .join('\n'), + ), ).toMatchSnapshot(); // Only a.js should be in the report - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(stdout).toMatch('a.js'); expect(stdout).not.toMatch('b.js'); diff --git a/e2e/__tests__/forceExit.test.js b/e2e/__tests__/forceExit.test.js index 11179a316c5e..34cb1f03682d 100644 --- a/e2e/__tests__/forceExit.test.js +++ b/e2e/__tests__/forceExit.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; diff --git a/e2e/__tests__/generatorMock.test.js b/e2e/__tests__/generatorMock.test.js index 310f655a1467..2d41feb01991 100644 --- a/e2e/__tests__/generatorMock.test.js +++ b/e2e/__tests__/generatorMock.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/global.test.js b/e2e/__tests__/global.test.js index 8702e60e2843..b0c1ef4f4069 100644 --- a/e2e/__tests__/global.test.js +++ b/e2e/__tests__/global.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; test('globals are properly defined', () => { expect(global.Object).toBe(Object); diff --git a/e2e/__tests__/globals.test.js b/e2e/__tests__/globals.test.js index 0a60e99d6b8d..63a8566267c8 100644 --- a/e2e/__tests__/globals.test.js +++ b/e2e/__tests__/globals.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import runJest from '../runJest'; @@ -18,6 +16,7 @@ import { extractSummary, writeFiles, } from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'globalVariables.test'); const TEST_DIR = path.resolve(DIR, '__tests__'); @@ -51,8 +50,8 @@ test('basic test constructs', () => { expect(status).toBe(0); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('skips', () => { @@ -81,8 +80,8 @@ test('skips', () => { const {stderr, status} = runJest(DIR); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(0); }); @@ -112,8 +111,8 @@ test('only', () => { expect(status).toBe(0); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('cannot have describe with no implementation', () => { @@ -128,8 +127,8 @@ test('cannot have describe with no implementation', () => { const rest = cleanStderr(stderr); const {summary} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('cannot test with no implementation', () => { @@ -145,8 +144,8 @@ test('cannot test with no implementation', () => { expect(status).toBe(1); const {summary} = extractSummary(stderr); - expect(cleanStderr(stderr)).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('skips with expand arg', () => { @@ -176,8 +175,8 @@ test('skips with expand arg', () => { expect(status).toBe(0); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('only with expand arg', () => { @@ -206,8 +205,8 @@ test('only with expand arg', () => { expect(status).toBe(0); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('cannot test with no implementation with expand arg', () => { @@ -223,8 +222,8 @@ test('cannot test with no implementation with expand arg', () => { expect(status).toBe(1); const {summary} = extractSummary(stderr); - expect(cleanStderr(stderr)).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(cleanStderr(stderr))).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('function as descriptor', () => { @@ -241,6 +240,6 @@ test('function as descriptor', () => { expect(status).toBe(0); const {summary, rest} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/hasteMapSha1.test.js b/e2e/__tests__/hasteMapSha1.test.js index 9a9fa2b28ae4..b7713d10b6a9 100644 --- a/e2e/__tests__/hasteMapSha1.test.js +++ b/e2e/__tests__/hasteMapSha1.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import os from 'os'; import path from 'path'; import JestHasteMap from 'jest-haste-map'; diff --git a/e2e/__tests__/hasteMapSize.test.js b/e2e/__tests__/hasteMapSize.test.js index 160bf08e0db6..32c3ff98dd7c 100644 --- a/e2e/__tests__/hasteMapSize.test.js +++ b/e2e/__tests__/hasteMapSize.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import os from 'os'; import path from 'path'; import HasteMap from 'jest-haste-map'; diff --git a/e2e/__tests__/jasmineAsync.test.js b/e2e/__tests__/jasmineAsync.test.js index f86aad6ecfca..f344e28a3bba 100644 --- a/e2e/__tests__/jasmineAsync.test.js +++ b/e2e/__tests__/jasmineAsync.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest, {json as runWithJson} from '../runJest'; describe('async jasmine', () => { diff --git a/e2e/__tests__/jasmineAsyncWithPendingDuringTest.js b/e2e/__tests__/jasmineAsyncWithPendingDuringTest.js index cfb24c9adc30..512935abe4cc 100644 --- a/e2e/__tests__/jasmineAsyncWithPendingDuringTest.js +++ b/e2e/__tests__/jasmineAsyncWithPendingDuringTest.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import {json as runWithJson} from '../runJest'; import {skipSuiteOnJestCircus} from '../../scripts/ConditionalTest'; diff --git a/e2e/__tests__/jest.config.js.test.js b/e2e/__tests__/jest.config.js.test.js index 3d11b56a7c88..ccf758c7a79a 100644 --- a/e2e/__tests__/jest.config.js.test.js +++ b/e2e/__tests__/jest.config.js.test.js @@ -7,11 +7,10 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../jest.config.js'); @@ -28,8 +27,8 @@ test('works with jest.config.js', () => { const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); const {rest, summary} = extractSummary(stderr); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('traverses directory tree up until it finds jest.config', () => { @@ -51,12 +50,14 @@ test('traverses directory tree up until it finds jest.config', () => { ); // Snapshot the console.loged `process.cwd()` and make sure it stays the same - expect(stdout.replace(/^\W+(.*)e2e/gm, '<>')).toMatchSnapshot(); + expect( + wrap(stdout.replace(/^\W+(.*)e2e/gm, '<>')), + ).toMatchSnapshot(); const {rest, summary} = extractSummary(stderr); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); test('invalid JS in jest.config.js', () => { diff --git a/e2e/__tests__/jestChangedFiles.test.js b/e2e/__tests__/jestChangedFiles.test.js index cdbbe646b706..6020514f44f3 100644 --- a/e2e/__tests__/jestChangedFiles.test.js +++ b/e2e/__tests__/jestChangedFiles.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import os from 'os'; import path from 'path'; import { @@ -18,6 +16,7 @@ import { import {skipSuiteOnWindows} from '../../scripts/ConditionalTest'; import {cleanup, run, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; skipSuiteOnWindows(); @@ -259,7 +258,7 @@ test('handles a bad revision for "changedSince", for git', async () => { const {status, stderr} = runJest(DIR, ['--changedSince=blablabla']); expect(status).toBe(1); - expect(stderr).toMatchSnapshot(); + expect(wrap(stderr)).toMatchSnapshot(); }); test('gets changed files for hg', async () => { @@ -406,5 +405,5 @@ test('handles a bad revision for "changedSince", for hg', async () => { const {status, stderr} = runJest(DIR, ['--changedSince=blablabla']); expect(status).toBe(1); - expect(stderr).toMatchSnapshot(); + expect(wrap(stderr)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/jestRequireActual.test.js b/e2e/__tests__/jestRequireActual.test.js index ad7e2ae975e3..411dced01860 100644 --- a/e2e/__tests__/jestRequireActual.test.js +++ b/e2e/__tests__/jestRequireActual.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import {cleanup, writeFiles} from '../Utils'; diff --git a/e2e/__tests__/jestRequireMock.test.js b/e2e/__tests__/jestRequireMock.test.js index eefe8c0bc577..d00058e97a78 100644 --- a/e2e/__tests__/jestRequireMock.test.js +++ b/e2e/__tests__/jestRequireMock.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import {cleanup, writeFiles} from '../Utils'; diff --git a/e2e/__tests__/json.test.js b/e2e/__tests__/json.test.js index 658057ec4217..df3e875203d2 100644 --- a/e2e/__tests__/json.test.js +++ b/e2e/__tests__/json.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; test('JSON is available in the global scope', () => { expect(JSON).toBe(global.JSON); diff --git a/e2e/__tests__/jsonReporter.test.js b/e2e/__tests__/jsonReporter.test.js index d7ae1a623f6e..7fe638ca623a 100644 --- a/e2e/__tests__/jsonReporter.test.js +++ b/e2e/__tests__/jsonReporter.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; diff --git a/e2e/__tests__/lifecycles.js b/e2e/__tests__/lifecycles.js index 2d36b32ec5d4..ea9977021725 100644 --- a/e2e/__tests__/lifecycles.js +++ b/e2e/__tests__/lifecycles.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/listTests.test.js b/e2e/__tests__/listTests.test.js index 641d3ed5bc9f..f7c4ad6cb7af 100644 --- a/e2e/__tests__/listTests.test.js +++ b/e2e/__tests__/listTests.test.js @@ -6,10 +6,10 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import path from 'path'; +import {wrap} from 'jest-snapshot-serializer-raw'; const testRootDir = path.resolve(__dirname, '..', '..'); @@ -26,10 +26,12 @@ describe('--listTests flag', () => { expect(status).toBe(0); expect( - normalizePaths(stdout) - .split('\n') - .sort() - .join('\n'), + wrap( + normalizePaths(stdout) + .split('\n') + .sort() + .join('\n'), + ), ).toMatchSnapshot(); }); @@ -39,10 +41,12 @@ describe('--listTests flag', () => { expect(status).toBe(0); expect(() => JSON.parse(stdout)).not.toThrow(); expect( - JSON.stringify( - JSON.parse(stdout) - .map(normalizePaths) - .sort(), + wrap( + JSON.stringify( + JSON.parse(stdout) + .map(normalizePaths) + .sort(), + ), ), ).toMatchSnapshot(); }); diff --git a/e2e/__tests__/locationInResults.test.js b/e2e/__tests__/locationInResults.test.js index 43ef16b6e666..3773f056c520 100644 --- a/e2e/__tests__/locationInResults.test.js +++ b/e2e/__tests__/locationInResults.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import {json as runWithJson} from '../runJest'; import {isJestCircusRun} from '../../scripts/ConditionalTest'; diff --git a/e2e/__tests__/logHeapUsage.test.js b/e2e/__tests__/logHeapUsage.test.js index 0ce1d4c9563b..2367d65ac8e2 100644 --- a/e2e/__tests__/logHeapUsage.test.js +++ b/e2e/__tests__/logHeapUsage.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import {cleanup, writeFiles} from '../Utils'; diff --git a/e2e/__tests__/mockNames.test.js b/e2e/__tests__/mockNames.test.js index dc76ad163ff5..40448c16e215 100644 --- a/e2e/__tests__/mockNames.test.js +++ b/e2e/__tests__/mockNames.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/moduleNameMapper.test.js b/e2e/__tests__/moduleNameMapper.test.js index 91d1809c1a5b..969b387372ed 100644 --- a/e2e/__tests__/moduleNameMapper.test.js +++ b/e2e/__tests__/moduleNameMapper.test.js @@ -6,17 +6,17 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('moduleNameMapper wrong configuration', () => { const {stderr, status} = runJest('module-name-mapper-wrong-config'); const {rest} = extractSummary(stderr); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('moduleNameMapper correct configuration', () => { @@ -26,5 +26,5 @@ test('moduleNameMapper correct configuration', () => { const {rest} = extractSummary(stderr); expect(status).toBe(0); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/moduleParentNullInTest.js b/e2e/__tests__/moduleParentNullInTest.js index 127a2d2a0e1e..0add10013a19 100644 --- a/e2e/__tests__/moduleParentNullInTest.js +++ b/e2e/__tests__/moduleParentNullInTest.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/multiProjectRunner.test.js b/e2e/__tests__/multiProjectRunner.test.js index 38d99dc29d9a..b423df611b51 100644 --- a/e2e/__tests__/multiProjectRunner.test.js +++ b/e2e/__tests__/multiProjectRunner.test.js @@ -7,13 +7,12 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; import stripAnsi from 'strip-ansi'; import {cleanup, extractSummary, sortLines, writeFiles} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'multi-project-runner-test'); @@ -91,7 +90,7 @@ test('can pass projects or global config', () => { 'The name `file1` was looked up in the Haste module map. It cannot be resolved, because there exists several different files', ); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); writeFiles(DIR, { 'global_config.js': ` @@ -116,8 +115,8 @@ test('can pass projects or global config', () => { ])); const result1 = extractSummary(stderr); - expect(result1.summary).toMatchSnapshot(); - expect(sortLines(result1.rest)).toMatchSnapshot(); + expect(wrap(result1.summary)).toMatchSnapshot(); + expect(wrap(sortLines(result1.rest))).toMatchSnapshot(); ({stderr} = runJest(DIR, [ '--no-watchman', @@ -127,8 +126,8 @@ test('can pass projects or global config', () => { ])); const result2 = extractSummary(stderr); - expect(result2.summary).toMatchSnapshot(); - expect(sortLines(result2.rest)).toMatchSnapshot(); + expect(wrap(result2.summary)).toMatchSnapshot(); + expect(wrap(sortLines(result2.rest))).toMatchSnapshot(); // make sure different ways of passing projects work exactly the same expect(result1.summary).toBe(result2.summary); diff --git a/e2e/__tests__/nativeAsyncMock.test.js b/e2e/__tests__/nativeAsyncMock.test.js index 994ac76b7754..2dde843752cd 100644 --- a/e2e/__tests__/nativeAsyncMock.test.js +++ b/e2e/__tests__/nativeAsyncMock.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import {extractSummary, run} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/nestedEventLoop.test.js b/e2e/__tests__/nestedEventLoop.test.js index 6629a8682b04..25731f2e108a 100644 --- a/e2e/__tests__/nestedEventLoop.test.js +++ b/e2e/__tests__/nestedEventLoop.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/noTestFound.test.js b/e2e/__tests__/noTestFound.test.js index c692f1a949c5..3d4e0a0bb6e3 100644 --- a/e2e/__tests__/noTestFound.test.js +++ b/e2e/__tests__/noTestFound.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/noTestsFound.test.js b/e2e/__tests__/noTestsFound.test.js index 6332dfa88a6b..360886aea33d 100644 --- a/e2e/__tests__/noTestsFound.test.js +++ b/e2e/__tests__/noTestsFound.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; diff --git a/e2e/__tests__/nodePath.test.js b/e2e/__tests__/nodePath.test.js index 2581c36a2acf..ee059732a931 100644 --- a/e2e/__tests__/nodePath.test.js +++ b/e2e/__tests__/nodePath.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/onlyChanged.test.js b/e2e/__tests__/onlyChanged.test.js index 1e0c36834b15..82282142fb8a 100644 --- a/e2e/__tests__/onlyChanged.test.js +++ b/e2e/__tests__/onlyChanged.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; diff --git a/e2e/__tests__/overrideGlobals.test.js b/e2e/__tests__/overrideGlobals.test.js index 6ca91e76fb43..32ee2177c7f7 100644 --- a/e2e/__tests__/overrideGlobals.test.js +++ b/e2e/__tests__/overrideGlobals.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; test('overriding native promise does not freeze Jest', () => { diff --git a/e2e/__tests__/presets.test.js b/e2e/__tests__/presets.test.js index 1c964f2ceb61..59ddb80556be 100644 --- a/e2e/__tests__/presets.test.js +++ b/e2e/__tests__/presets.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/processExit.test.js b/e2e/__tests__/processExit.test.js index 4375a3091c4d..1290e1b42aa1 100644 --- a/e2e/__tests__/processExit.test.js +++ b/e2e/__tests__/processExit.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; it('prints stack trace pointing to process.exit call', async () => { const {stderr} = await runJest('process-exit'); - expect(stderr).toMatchSnapshot(); + expect(wrap(stderr)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/promiseReject.test.js b/e2e/__tests__/promiseReject.test.js index 38620a5da78f..1b1b75dce106 100644 --- a/e2e/__tests__/promiseReject.test.js +++ b/e2e/__tests__/promiseReject.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import path from 'path'; diff --git a/e2e/__tests__/regexCharInPath.test.js b/e2e/__tests__/regexCharInPath.test.js index 2740d212af58..cfae71161bca 100644 --- a/e2e/__tests__/regexCharInPath.test.js +++ b/e2e/__tests__/regexCharInPath.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import {json as runWithJson} from '../runJest'; diff --git a/e2e/__tests__/requireAfterTeardown.test.js b/e2e/__tests__/requireAfterTeardown.test.js index ed868db4b7df..d47ed9a898bd 100644 --- a/e2e/__tests__/requireAfterTeardown.test.js +++ b/e2e/__tests__/requireAfterTeardown.test.js @@ -7,9 +7,8 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('prints useful error for requires after test is done', () => { const {stderr} = runJest('require-after-teardown'); @@ -19,7 +18,7 @@ test('prints useful error for requires after test is done', () => { .slice(9, 18) .join('\n'); - expect(interestingLines).toMatchSnapshot(); + expect(wrap(interestingLines)).toMatchSnapshot(); expect(stderr.split('\n')[19]).toMatch( new RegExp('(__tests__/lateRequire.test.js:11:20)'), ); diff --git a/e2e/__tests__/requireMain.test.js b/e2e/__tests__/requireMain.test.js index 5f466b486245..34a95324d07c 100644 --- a/e2e/__tests__/requireMain.test.js +++ b/e2e/__tests__/requireMain.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; test('provides `require.main` set to test suite module', () => { diff --git a/e2e/__tests__/resetModules.test.js b/e2e/__tests__/resetModules.test.js index b2a7fef3548c..a87314b3e885 100644 --- a/e2e/__tests__/resetModules.test.js +++ b/e2e/__tests__/resetModules.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/resolve.test.js b/e2e/__tests__/resolve.test.js index 8979de96001d..a455c02e7045 100644 --- a/e2e/__tests__/resolve.test.js +++ b/e2e/__tests__/resolve.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/resolveGetPaths.test.js b/e2e/__tests__/resolveGetPaths.test.js index 4a455594f22d..8afd511abc01 100644 --- a/e2e/__tests__/resolveGetPaths.test.js +++ b/e2e/__tests__/resolveGetPaths.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/resolveNoFileExtensions.test.js b/e2e/__tests__/resolveNoFileExtensions.test.js index 1354556e047f..535cbb8af7c4 100644 --- a/e2e/__tests__/resolveNoFileExtensions.test.js +++ b/e2e/__tests__/resolveNoFileExtensions.test.js @@ -6,11 +6,11 @@ * * @flow */ -'use strict'; import path from 'path'; import runJest from '../runJest'; import {cleanup, extractSummary, writeFiles} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../resolve-no-extensions-no-js'); @@ -22,7 +22,7 @@ test('show error message with matching files', () => { const {rest} = extractSummary(stderr); expect(status).toBe(1); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('show error message when no js moduleFileExtensions', () => { @@ -49,5 +49,5 @@ test('show error message when no js moduleFileExtensions', () => { const {status, stderr} = runJest('resolve-no-extensions-no-js'); expect(status).toBe(1); - expect(stderr).toMatchSnapshot(); + expect(wrap(stderr)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/resolveNodeModule.test.js b/e2e/__tests__/resolveNodeModule.test.js index 8300aa01293e..e5949480c346 100644 --- a/e2e/__tests__/resolveNodeModule.test.js +++ b/e2e/__tests__/resolveNodeModule.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/resolveWithPaths.test.js b/e2e/__tests__/resolveWithPaths.test.js index 7e679918f6e0..ce60bc6b3290 100644 --- a/e2e/__tests__/resolveWithPaths.test.js +++ b/e2e/__tests__/resolveWithPaths.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import {resolve} from 'path'; import runJest from '../runJest'; diff --git a/e2e/__tests__/runTestsByPath.test.js b/e2e/__tests__/runTestsByPath.test.js index 14d29b9d5dd5..0d487e7e70bf 100644 --- a/e2e/__tests__/runTestsByPath.test.js +++ b/e2e/__tests__/runTestsByPath.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; diff --git a/e2e/__tests__/runtimeInternalModuleRegistry.test.js b/e2e/__tests__/runtimeInternalModuleRegistry.test.js index 9a2e302e6e74..91ee8c41ede1 100644 --- a/e2e/__tests__/runtimeInternalModuleRegistry.test.js +++ b/e2e/__tests__/runtimeInternalModuleRegistry.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import {json as runWithJson} from '../runJest'; diff --git a/e2e/__tests__/setImmediate.test.js b/e2e/__tests__/setImmediate.test.js index c7c4588cb560..134b886181c1 100644 --- a/e2e/__tests__/setImmediate.test.js +++ b/e2e/__tests__/setImmediate.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/setupFilesAfterEnvConfig.test.js b/e2e/__tests__/setupFilesAfterEnvConfig.test.js index a2ec3b6a3f38..24f18cbf499d 100644 --- a/e2e/__tests__/setupFilesAfterEnvConfig.test.js +++ b/e2e/__tests__/setupFilesAfterEnvConfig.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; diff --git a/e2e/__tests__/showConfig.test.js b/e2e/__tests__/showConfig.test.js index 013ae8f7ad24..5b67d26761d0 100644 --- a/e2e/__tests__/showConfig.test.js +++ b/e2e/__tests__/showConfig.test.js @@ -7,13 +7,12 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import os from 'os'; import {skipSuiteOnWindows} from '../../scripts/ConditionalTest'; import {cleanup, writeFiles} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; skipSuiteOnWindows(); @@ -43,5 +42,5 @@ test('--showConfig outputs config info and exits', () => { .replace(/\"\S*show-config-test/gm, '"<>') .replace(/\"\S*\/jest\/packages/gm, '"<>'); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/snapshot.test.js b/e2e/__tests__/snapshot.test.js index 8153bab57fe9..561916e63faf 100644 --- a/e2e/__tests__/snapshot.test.js +++ b/e2e/__tests__/snapshot.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; import {extractSummary} from '../Utils'; import runJest, {json as runWithJson} from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const emptyTest = 'describe("", () => {it("", () => {})})'; const snapshotDir = path.resolve( @@ -116,7 +116,7 @@ describe('Snapshot', () => { ).not.toBeUndefined(); expect(result.stderr).toMatch('5 snapshots written from 2 test suites'); - expect(extractSummary(result.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(result.stderr).summary)).toMatchSnapshot(); }); it('works with escaped characters', () => { @@ -130,7 +130,7 @@ describe('Snapshot', () => { expect(stderr).toMatch('1 snapshot written'); expect(result.status).toBe(0); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); // Write the second snapshot const testData = @@ -148,7 +148,7 @@ describe('Snapshot', () => { stderr = result.stderr; expect(stderr).toMatch('1 snapshot written'); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(result.status).toBe(0); // Now let's check again if everything still passes. @@ -161,7 +161,7 @@ describe('Snapshot', () => { stderr = result.stderr; expect(stderr).not.toMatch('Snapshot Summary'); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(result.status).toBe(0); }); @@ -176,7 +176,7 @@ describe('Snapshot', () => { expect(stderr).toMatch('2 snapshots written from 1 test suite.'); expect(result.status).toBe(0); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); result = runJest('snapshot-escape', [ '-w=1', @@ -188,7 +188,7 @@ describe('Snapshot', () => { // Make sure we aren't writing a snapshot this time which would // indicate that the snapshot couldn't be loaded properly. expect(stderr).not.toMatch('Snapshot Summary'); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(result.status).toBe(0); }); @@ -203,7 +203,7 @@ describe('Snapshot', () => { expect(stderr).toMatch('1 snapshot written'); expect(result.status).toBe(0); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); result = runJest('snapshot-escape', [ '-w=1', @@ -215,7 +215,7 @@ describe('Snapshot', () => { // Make sure we aren't writing a snapshot this time which would // indicate that the snapshot couldn't be loaded properly. expect(stderr).not.toMatch('1 snapshot written'); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(result.status).toBe(0); }); @@ -234,7 +234,7 @@ describe('Snapshot', () => { const {rest, summary} = extractSummary(result.stderr); expect(rest).toMatch('New snapshot was not written'); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); it('works on subsequent runs without `-u`', () => { @@ -251,8 +251,8 @@ describe('Snapshot', () => { expect(firstRun.stderr).toMatch('9 snapshots written from 3 test suites'); expect(secondRun.stderr).toMatch('9 passed, 9 total'); - expect(extractSummary(firstRun.stderr).summary).toMatchSnapshot(); - expect(extractSummary(secondRun.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(firstRun.stderr).summary)).toMatchSnapshot(); + expect(wrap(extractSummary(secondRun.stderr).summary)).toMatchSnapshot(); }); it('deletes the snapshot if the test suite has been removed', () => { @@ -272,8 +272,8 @@ describe('Snapshot', () => { expect(secondRun.stderr).toMatch( '1 snapshot file removed from 1 test suite', ); - expect(extractSummary(firstRun.stderr).summary).toMatchSnapshot(); - expect(extractSummary(secondRun.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(firstRun.stderr).summary)).toMatchSnapshot(); + expect(wrap(extractSummary(secondRun.stderr).summary)).toMatchSnapshot(); }); it('deletes a snapshot when a test does removes all the snapshots', () => { @@ -291,8 +291,8 @@ describe('Snapshot', () => { expect(secondRun.stderr).toMatch( '1 snapshot file removed from 1 test suite', ); - expect(extractSummary(firstRun.stderr).summary).toMatchSnapshot(); - expect(extractSummary(secondRun.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(firstRun.stderr).summary)).toMatchSnapshot(); + expect(wrap(extractSummary(secondRun.stderr).summary)).toMatchSnapshot(); }); it('updates the snapshot when a test removes some snapshots', () => { @@ -324,10 +324,10 @@ describe('Snapshot', () => { expect(beforeRemovingSnapshot[keyToCheck]).not.toBe(undefined); expect(afterRemovingSnapshot[keyToCheck]).toBe(undefined); - expect(extractSummary(firstRun.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(firstRun.stderr).summary)).toMatchSnapshot(); expect(firstRun.stderr).toMatch('9 snapshots written from 3 test suites'); - expect(extractSummary(secondRun.stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(secondRun.stderr).summary)).toMatchSnapshot(); expect(secondRun.stderr).toMatch('1 snapshot updated from 1 test suite'); expect(secondRun.stderr).toMatch('1 snapshot removed from 1 test suite'); }); diff --git a/e2e/__tests__/snapshotMockFs.test.js b/e2e/__tests__/snapshotMockFs.test.js index 6e9af87bdc0b..65bc709b75e1 100644 --- a/e2e/__tests__/snapshotMockFs.test.js +++ b/e2e/__tests__/snapshotMockFs.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; -const rimraf = require('rimraf'); -const path = require('path'); -const {extractSummary} = require('../Utils'); -const runJest = require('../runJest'); +import path from 'path'; +import rimraf from 'rimraf'; +import {wrap} from 'jest-snapshot-serializer-raw'; +import {extractSummary} from '../Utils'; +import {json as runJestJson} from '../runJest'; const DIR = path.resolve(__dirname, '../snapshot-mock-fs'); const snapshotDir = path.resolve(DIR, '__tests__/__snapshots__'); @@ -21,14 +21,14 @@ beforeEach(() => rimraf.sync(snapshotDir)); afterAll(() => rimraf.sync(snapshotDir)); test('store snapshot even if fs is mocked', () => { - const {json, status, stderr} = runJest.json(DIR, ['--ci=false']); + const {json, status, stderr} = runJestJson(DIR, ['--ci=false']); expect(status).toBe(0); expect(json.numTotalTests).toBe(1); expect(json.numPassedTests).toBe(1); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); // $FlowFixMe dynamic require const content = require(snapshotFile); diff --git a/e2e/__tests__/snapshotResolver.test.js b/e2e/__tests__/snapshotResolver.test.js index e21d7f52cd64..cd5fbaaa4cc2 100644 --- a/e2e/__tests__/snapshotResolver.test.js +++ b/e2e/__tests__/snapshotResolver.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import fs from 'fs'; import path from 'path'; import runJest from '../runJest'; diff --git a/e2e/__tests__/snapshotSerializers.test.js b/e2e/__tests__/snapshotSerializers.test.js index 2871db40b688..7991000917b3 100644 --- a/e2e/__tests__/snapshotSerializers.test.js +++ b/e2e/__tests__/snapshotSerializers.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import path from 'path'; import {cleanup} from '../Utils'; diff --git a/e2e/__tests__/stackTrace.test.js b/e2e/__tests__/stackTrace.test.js index f0a88a613371..68a06d982101 100644 --- a/e2e/__tests__/stackTrace.test.js +++ b/e2e/__tests__/stackTrace.test.js @@ -6,16 +6,16 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; describe('Stack Trace', () => { it('prints a stack trace for runtime errors', () => { const {status, stderr} = runJest('stack-trace', ['runtimeError.test.js']); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).toMatch( @@ -33,7 +33,7 @@ describe('Stack Trace', () => { '--noStackTrace', ]); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).toMatch( @@ -47,7 +47,7 @@ describe('Stack Trace', () => { it('prints a stack trace for matching errors', () => { const {status, stderr} = runJest('stack-trace', ['stackTrace.test.js']); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).toMatch(/\s+at\s(?:.+?)\s\(__tests__\/stackTrace.test\.js/); @@ -59,7 +59,7 @@ describe('Stack Trace', () => { '--noStackTrace', ]); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).not.toMatch( @@ -70,7 +70,7 @@ describe('Stack Trace', () => { it('prints a stack trace for errors', () => { const {status, stderr} = runJest('stack-trace', ['testError.test.js']); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).toMatch(/this is unexpected\./); @@ -93,7 +93,7 @@ describe('Stack Trace', () => { 'stackTraceWithoutMessage.test.js', ]); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).toMatch(/important message/); @@ -108,7 +108,7 @@ describe('Stack Trace', () => { '--noStackTrace', ]); - expect(extractSummary(stderr).summary).toMatchSnapshot(); + expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot(); expect(status).toBe(1); expect(stderr).not.toMatch( diff --git a/e2e/__tests__/stackTraceNoCaptureStackTrace.test.js b/e2e/__tests__/stackTraceNoCaptureStackTrace.test.js index 26ee4498b646..39de7122b30a 100644 --- a/e2e/__tests__/stackTraceNoCaptureStackTrace.test.js +++ b/e2e/__tests__/stackTraceNoCaptureStackTrace.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/stackTraceSourceMaps.test.js b/e2e/__tests__/stackTraceSourceMaps.test.js index 02fddcfd0660..162cabc65085 100644 --- a/e2e/__tests__/stackTraceSourceMaps.test.js +++ b/e2e/__tests__/stackTraceSourceMaps.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import {run} from '../Utils'; import runJest from '../runJest'; diff --git a/e2e/__tests__/supportsDashedArgs.js b/e2e/__tests__/supportsDashedArgs.js index 240b1486fcf9..101d156bbfd0 100644 --- a/e2e/__tests__/supportsDashedArgs.js +++ b/e2e/__tests__/supportsDashedArgs.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; diff --git a/e2e/__tests__/symbol.test.js b/e2e/__tests__/symbol.test.js index 4ae1dbd53c1f..56629c1d89ff 100644 --- a/e2e/__tests__/symbol.test.js +++ b/e2e/__tests__/symbol.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - test('Symbol deletion', () => { global.Symbol = undefined; diff --git a/e2e/__tests__/testEnvironment.test.js b/e2e/__tests__/testEnvironment.test.js index 337ddaab79ba..239b60efe742 100644 --- a/e2e/__tests__/testEnvironment.test.js +++ b/e2e/__tests__/testEnvironment.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import {json as runWithJson} from '../runJest'; diff --git a/e2e/__tests__/testEnvironmentAsync.test.js b/e2e/__tests__/testEnvironmentAsync.test.js index 29b447f7f534..d866e519d96e 100644 --- a/e2e/__tests__/testEnvironmentAsync.test.js +++ b/e2e/__tests__/testEnvironmentAsync.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; diff --git a/e2e/__tests__/testFailureExitCode.test.js b/e2e/__tests__/testFailureExitCode.test.js index 2fd1e4ad171b..c22ad3061897 100644 --- a/e2e/__tests__/testFailureExitCode.test.js +++ b/e2e/__tests__/testFailureExitCode.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import {cleanup, writeFiles} from '../Utils'; diff --git a/e2e/__tests__/testInRoot.test.js b/e2e/__tests__/testInRoot.test.js index 625cbbd0d22f..1dc86f6e2f4d 100644 --- a/e2e/__tests__/testInRoot.test.js +++ b/e2e/__tests__/testInRoot.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import path from 'path'; import {json as runWithJson} from '../runJest'; diff --git a/e2e/__tests__/testNamePattern.test.js b/e2e/__tests__/testNamePattern.test.js index 6c47547cf66f..bb89cc5a1c13 100644 --- a/e2e/__tests__/testNamePattern.test.js +++ b/e2e/__tests__/testNamePattern.test.js @@ -6,10 +6,10 @@ * * @flow */ -'use strict'; import {extractSummary} from '../Utils'; import {json as runWithJson} from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('testNamePattern', () => { const {stderr, status} = runWithJson('test-name-pattern', [ @@ -19,5 +19,5 @@ test('testNamePattern', () => { const {summary} = extractSummary(stderr); expect(status).toBe(0); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/testNamePatternSkipped.test.js b/e2e/__tests__/testNamePatternSkipped.test.js index 5bb7fbe23701..7dceeede0c81 100644 --- a/e2e/__tests__/testNamePatternSkipped.test.js +++ b/e2e/__tests__/testNamePatternSkipped.test.js @@ -6,10 +6,10 @@ * * @flow */ -'use strict'; import {extractSummary} from '../Utils'; import {json as runWithJson} from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; test('testNamePattern skipped', () => { const {stderr, status} = runWithJson('test-name-pattern-skipped', [ @@ -19,5 +19,5 @@ test('testNamePattern skipped', () => { const {summary} = extractSummary(stderr); expect(status).toBe(0); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/testRetries.test.js b/e2e/__tests__/testRetries.test.js index ed5f7504db89..0a726f5df8f1 100644 --- a/e2e/__tests__/testRetries.test.js +++ b/e2e/__tests__/testRetries.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import fs from 'fs'; import path from 'path'; diff --git a/e2e/__tests__/testTodo.test.js b/e2e/__tests__/testTodo.test.js index d6c24febbbee..aaedf2b9be23 100644 --- a/e2e/__tests__/testTodo.test.js +++ b/e2e/__tests__/testTodo.test.js @@ -7,37 +7,36 @@ * @flow */ -'use strict'; - import path from 'path'; import runJest from '../runJest'; import {extractSummary} from '../Utils'; +import {wrap} from 'jest-snapshot-serializer-raw'; const dir = path.resolve(__dirname, '../test-todo'); test('works with all statuses', () => { const result = runJest(dir, ['statuses.test.js']); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('shows error messages when called with no arguments', () => { const result = runJest(dir, ['todoNoArgs.test.js']); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('shows error messages when called with multiple arguments', () => { const result = runJest(dir, ['todoMultipleArgs.test.js']); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); test('shows error messages when called with invalid argument', () => { const result = runJest(dir, ['todoNonString.test.js']); expect(result.status).toBe(1); const {rest} = extractSummary(result.stderr); - expect(rest).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/timeouts.test.js b/e2e/__tests__/timeouts.test.js index 9e75a41749ef..14a8f609d759 100644 --- a/e2e/__tests__/timeouts.test.js +++ b/e2e/__tests__/timeouts.test.js @@ -11,6 +11,7 @@ import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../timeouts'); @@ -36,7 +37,7 @@ test('exceeds the timeout', () => { expect(rest).toMatch( /(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/, ); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(1); }); @@ -56,7 +57,7 @@ test('does not exceed the timeout', () => { const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); const {rest, summary} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(0); }); diff --git a/e2e/__tests__/timeoutsLegacy.test.js b/e2e/__tests__/timeoutsLegacy.test.js index f268d4838e5b..d5fe3e816f0f 100644 --- a/e2e/__tests__/timeoutsLegacy.test.js +++ b/e2e/__tests__/timeoutsLegacy.test.js @@ -12,6 +12,7 @@ import path from 'path'; import {cleanup, extractSummary, writeFiles} from '../Utils'; import runJest from '../runJest'; import {skipSuiteOnJestCircus} from '../../scripts/ConditionalTest'; +import {wrap} from 'jest-snapshot-serializer-raw'; /** * NOTE: This test should be removed once jest-circus is rolled out as a breaking change. @@ -43,7 +44,7 @@ test('exceeds the timeout set using jasmine.DEFAULT_TIMEOUT_INTERVAL', () => { expect(rest).toMatch( /(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/, ); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(1); }); @@ -63,8 +64,8 @@ test('does not exceed the timeout using jasmine.DEFAULT_TIMEOUT_INTERVAL', () => const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); const {rest, summary} = extractSummary(stderr); - expect(rest).toMatchSnapshot(); - expect(summary).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(0); }); @@ -85,6 +86,6 @@ test('can read and write jasmine.DEFAULT_TIMEOUT_INTERVAL', () => { const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false']); const {summary} = extractSummary(stderr); - expect(summary).toMatchSnapshot(); + expect(wrap(summary)).toMatchSnapshot(); expect(status).toBe(0); }); diff --git a/e2e/__tests__/timerResetMocks.test.js b/e2e/__tests__/timerResetMocks.test.js index 8bda44603ce5..8b0a0ec4608d 100644 --- a/e2e/__tests__/timerResetMocks.test.js +++ b/e2e/__tests__/timerResetMocks.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/timerUseRealTimers.test.js b/e2e/__tests__/timerUseRealTimers.test.js index 0bf091b2bbb4..b1fe0f7bbe2d 100644 --- a/e2e/__tests__/timerUseRealTimers.test.js +++ b/e2e/__tests__/timerUseRealTimers.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/toMatchInlineSnapshot.test.js b/e2e/__tests__/toMatchInlineSnapshot.test.js index 3bd85ffedd34..41c7e42bc283 100644 --- a/e2e/__tests__/toMatchInlineSnapshot.test.js +++ b/e2e/__tests__/toMatchInlineSnapshot.test.js @@ -11,6 +11,7 @@ import fs from 'fs'; import path from 'path'; import {cleanup, makeTemplate, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../to-match-inline-snapshot'); const TESTS_DIR = path.resolve(DIR, '__tests__'); @@ -35,7 +36,7 @@ test('basic support', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('initial write'); + expect(wrap(fileAfter)).toMatchSnapshot('initial write'); } { @@ -44,7 +45,7 @@ test('basic support', () => { expect(stderr).toMatch('Snapshots: 1 passed, 1 total'); expect(stderr).not.toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('snapshot passed'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot passed'); } { @@ -55,7 +56,7 @@ test('basic support', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('Received value does not match stored snapshot'); expect(status).toBe(1); - expect(fileAfter).toMatchSnapshot('snapshot mismatch'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot mismatch'); } { @@ -68,7 +69,7 @@ test('basic support', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot updated from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('snapshot updated'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot updated'); } }); @@ -85,7 +86,7 @@ test('handles property matchers', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('initial write'); + expect(wrap(fileAfter)).toMatchSnapshot('initial write'); } { @@ -93,7 +94,7 @@ test('handles property matchers', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('Snapshots: 1 passed, 1 total'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('snapshot passed'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot passed'); } { @@ -107,7 +108,7 @@ test('handles property matchers', () => { ); expect(stderr).toMatch('Snapshots: 1 failed, 1 total'); expect(status).toBe(1); - expect(fileAfter).toMatchSnapshot('snapshot failed'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot failed'); } { @@ -123,7 +124,7 @@ test('handles property matchers', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot updated from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('snapshot updated'); + expect(wrap(fileAfter)).toMatchSnapshot('snapshot updated'); } }); @@ -146,7 +147,7 @@ test('removes obsolete external snapshots', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('initial write'); + expect(wrap(fileAfter)).toMatchSnapshot('initial write'); expect(fs.existsSync(snapshotPath)).toEqual(true); } @@ -156,7 +157,7 @@ test('removes obsolete external snapshots', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('Snapshots: 1 obsolete, 1 written, 1 total'); expect(status).toBe(1); - expect(fileAfter).toMatchSnapshot('inline snapshot written'); + expect(wrap(fileAfter)).toMatchSnapshot('inline snapshot written'); expect(fs.existsSync(snapshotPath)).toEqual(true); } @@ -170,7 +171,7 @@ test('removes obsolete external snapshots', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('Snapshots: 1 file removed, 1 passed, 1 total'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot('external snapshot cleaned'); + expect(wrap(fileAfter)).toMatchSnapshot('external snapshot cleaned'); expect(fs.existsSync(snapshotPath)).toEqual(false); } }); @@ -189,7 +190,7 @@ test('supports async matchers', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('2 snapshots written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot(); + expect(wrap(fileAfter)).toMatchSnapshot(); }); test('supports async tests', () => { @@ -206,7 +207,7 @@ test('supports async tests', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot(); + expect(wrap(fileAfter)).toMatchSnapshot(); }); test('writes snapshots with non-literals in expect(...)', () => { @@ -223,7 +224,7 @@ test('writes snapshots with non-literals in expect(...)', () => { const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); expect(status).toBe(0); - expect(fileAfter).toMatchSnapshot(); + expect(wrap(fileAfter)).toMatchSnapshot(); }); // issue: https://github.com/facebook/jest/issues/6702 diff --git a/e2e/__tests__/toThrowErrorMatchingInlineSnapshot.test.js b/e2e/__tests__/toThrowErrorMatchingInlineSnapshot.test.js index e2bb075cd961..75013e055a00 100644 --- a/e2e/__tests__/toThrowErrorMatchingInlineSnapshot.test.js +++ b/e2e/__tests__/toThrowErrorMatchingInlineSnapshot.test.js @@ -11,6 +11,7 @@ import path from 'path'; import fs from 'fs'; import {cleanup, makeTemplate, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve( __dirname, @@ -40,7 +41,7 @@ test('works fine when function throws error', () => { const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]); const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); - expect(fileAfter).toMatchSnapshot('initial write'); + expect(wrap(fileAfter)).toMatchSnapshot('initial write'); expect(status).toBe(0); } }); @@ -66,7 +67,7 @@ test('updates existing snapshot', () => { ]); const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot updated from 1 test suite.'); - expect(fileAfter).toMatchSnapshot('updated snapshot'); + expect(wrap(fileAfter)).toMatchSnapshot('updated snapshot'); expect(status).toBe(0); } }); @@ -102,6 +103,6 @@ test('should support rejecting promises', () => { const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]); const fileAfter = readFile(filename); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); - expect(fileAfter).toMatchSnapshot(); + expect(wrap(fileAfter)).toMatchSnapshot(); expect(status).toBe(0); }); diff --git a/e2e/__tests__/toThrowErrorMatchingSnapshot.test.js b/e2e/__tests__/toThrowErrorMatchingSnapshot.test.js index bfcebc9c20c3..626069f54857 100644 --- a/e2e/__tests__/toThrowErrorMatchingSnapshot.test.js +++ b/e2e/__tests__/toThrowErrorMatchingSnapshot.test.js @@ -11,6 +11,7 @@ import path from 'path'; import fs from 'fs'; import {cleanup, makeTemplate, writeFiles} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(__dirname, '../to-throw-error-matching-snapshot'); const TESTS_DIR = path.resolve(DIR, '__tests__'); @@ -99,7 +100,7 @@ test('should support rejecting promises', () => { ); expect(stderr).toMatch('1 snapshot written from 1 test suite.'); - expect(snapshot).toMatchSnapshot(); + expect(wrap(snapshot)).toMatchSnapshot(); expect(status).toBe(0); } }); diff --git a/e2e/__tests__/transform.test.js b/e2e/__tests__/transform.test.js index 56792bb98557..50dba3b10f26 100644 --- a/e2e/__tests__/transform.test.js +++ b/e2e/__tests__/transform.test.js @@ -17,6 +17,7 @@ import { } from '../Utils'; import runJest, {json as runWithJson} from '../runJest'; import os from 'os'; +import {wrap} from 'jest-snapshot-serializer-raw'; describe('babel-jest', () => { const dir = path.resolve(__dirname, '..', 'transform/babel-jest'); @@ -40,7 +41,7 @@ describe('babel-jest', () => { expect(stdout).not.toMatch('notCovered.js'); expect(stdout).not.toMatch('excludedFromCoverage.js'); // coverage result should not change - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); }); @@ -73,7 +74,7 @@ describe('no babel-jest', () => { expect(stdout).toMatch('covered.js'); expect(stdout).not.toMatch('excludedFromCoverage.js'); // coverage result should not change - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); }); @@ -98,7 +99,7 @@ describe('custom transformer', () => { stripAnsi: true, }); // coverage should be empty because there's no real instrumentation - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); expect(status).toBe(0); }); }); diff --git a/e2e/__tests__/transformLinkedModules.test.js b/e2e/__tests__/transformLinkedModules.test.js index 5444d507c8f0..3866b1411c35 100644 --- a/e2e/__tests__/transformLinkedModules.test.js +++ b/e2e/__tests__/transformLinkedModules.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import {json as runWithJson} from '../runJest'; it('should transform linked modules', () => { diff --git a/e2e/__tests__/typescriptCoverage.test.js b/e2e/__tests__/typescriptCoverage.test.js index d7f31e2d66d4..5c13681302fe 100644 --- a/e2e/__tests__/typescriptCoverage.test.js +++ b/e2e/__tests__/typescriptCoverage.test.js @@ -10,6 +10,7 @@ import path from 'path'; import {run} from '../Utils'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; it('instruments and collects coverage for typescript files', () => { const dir = path.resolve(__dirname, '../typescript-coverage'); @@ -17,5 +18,5 @@ it('instruments and collects coverage for typescript files', () => { const {stdout} = runJest(dir, ['--coverage', '--no-cache'], { stripAnsi: true, }); - expect(stdout).toMatchSnapshot(); + expect(wrap(stdout)).toMatchSnapshot(); }); diff --git a/e2e/__tests__/unexpectedToken.test.js b/e2e/__tests__/unexpectedToken.test.js index 38980ab94358..7bf053296c97 100644 --- a/e2e/__tests__/unexpectedToken.test.js +++ b/e2e/__tests__/unexpectedToken.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; diff --git a/e2e/__tests__/useStderr.test.js b/e2e/__tests__/useStderr.test.js index e7e217c7f027..d741fe5317da 100644 --- a/e2e/__tests__/useStderr.test.js +++ b/e2e/__tests__/useStderr.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import runJest from '../runJest'; import os from 'os'; import path from 'path'; diff --git a/e2e/__tests__/verbose.test.js b/e2e/__tests__/verbose.test.js index a1b37733beeb..5ad4d428b312 100644 --- a/e2e/__tests__/verbose.test.js +++ b/e2e/__tests__/verbose.test.js @@ -6,7 +6,6 @@ * * @flow */ -'use strict'; import runJest from '../runJest'; diff --git a/e2e/__tests__/version.test.js b/e2e/__tests__/version.test.js index 9150d2a9425b..5fbe936a7464 100644 --- a/e2e/__tests__/version.test.js +++ b/e2e/__tests__/version.test.js @@ -7,8 +7,6 @@ * @flow */ -'use strict'; - import path from 'path'; import os from 'os'; import {cleanup, writeFiles} from '../Utils'; diff --git a/e2e/__tests__/watchModeOnlyFailed.test.js b/e2e/__tests__/watchModeOnlyFailed.test.js index 09e50945c8ad..fea5a4165872 100644 --- a/e2e/__tests__/watchModeOnlyFailed.test.js +++ b/e2e/__tests__/watchModeOnlyFailed.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import path from 'path'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import os from 'os'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'watch-mode-only-failed'); const pluginPath = path.resolve(__dirname, '../MockStdinWatchPlugin'); @@ -50,8 +50,8 @@ test('can press "f" to run only failed tests', () => { expect(results).toHaveLength(2); results.forEach(({rest, summary}) => { - expect(rest).toMatchSnapshot('test results'); - expect(summary).toMatchSnapshot('test summary'); + expect(wrap(rest)).toMatchSnapshot('test results'); + expect(wrap(summary)).toMatchSnapshot('test summary'); }); expect(status).toBe(0); }); diff --git a/e2e/__tests__/watchModePatterns.test.js b/e2e/__tests__/watchModePatterns.test.js index 66a3cfb1442a..d21e26cda6e6 100644 --- a/e2e/__tests__/watchModePatterns.test.js +++ b/e2e/__tests__/watchModePatterns.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import path from 'path'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import os from 'os'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'watch-mode-patterns'); const pluginPath = path.resolve(__dirname, '../MockStdinWatchPlugin'); @@ -53,11 +53,12 @@ test('can press "p" to filter by file name', () => { ]); const results = extractSummaries(stderr); + // contains ansi characters, should not use `wrap` expect(stdout).toMatchSnapshot(); expect(results).toHaveLength(2); results.forEach(({rest, summary}) => { - expect(rest).toMatchSnapshot('test results'); - expect(summary).toMatchSnapshot('test summary'); + expect(wrap(rest)).toMatchSnapshot('test results'); + expect(wrap(summary)).toMatchSnapshot('test summary'); }); expect(status).toBe(0); }); @@ -72,11 +73,12 @@ test('can press "t" to filter by test name', () => { ]); const results = extractSummaries(stderr); + // contains ansi characters, should not use `wrap` expect(stdout).toMatchSnapshot(); expect(results).toHaveLength(2); results.forEach(({rest, summary}) => { - expect(rest).toMatchSnapshot('test results'); - expect(summary).toMatchSnapshot('test summary'); + expect(wrap(rest)).toMatchSnapshot('test results'); + expect(wrap(summary)).toMatchSnapshot('test summary'); }); expect(status).toBe(0); }); diff --git a/e2e/__tests__/watchModeUpdateSnapshot.test.js b/e2e/__tests__/watchModeUpdateSnapshot.test.js index 872a9e2c13a7..21bd3ba32b27 100644 --- a/e2e/__tests__/watchModeUpdateSnapshot.test.js +++ b/e2e/__tests__/watchModeUpdateSnapshot.test.js @@ -6,12 +6,12 @@ * * @flow */ -'use strict'; import path from 'path'; import {cleanup, extractSummaries, writeFiles} from '../Utils'; import os from 'os'; import runJest from '../runJest'; +import {wrap} from 'jest-snapshot-serializer-raw'; const DIR = path.resolve(os.tmpdir(), 'watch-mode-update-snapshot'); const pluginPath = path.resolve(__dirname, '../MockStdinWatchPlugin'); @@ -50,8 +50,8 @@ test('can press "u" to update snapshots', () => { const results = extractSummaries(stderr); expect(results).toHaveLength(2); results.forEach(({rest, summary}) => { - expect(rest).toMatchSnapshot('test results'); - expect(summary).toMatchSnapshot('test summary'); + expect(wrap(rest)).toMatchSnapshot('test results'); + expect(wrap(summary)).toMatchSnapshot('test summary'); }); expect(status).toBe(0); }); diff --git a/jest.config.js b/jest.config.js index e1f673d6c471..60282c23ef0a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,6 +26,7 @@ module.exports = { setupFilesAfterEnv: ['/testSetupFile.js'], snapshotSerializers: [ '/packages/pretty-format/build/plugins/ConvertAnsi.js', + 'jest-snapshot-serializer-raw', ], testEnvironment: './packages/jest-environment-node', testPathIgnorePatterns: [ diff --git a/package.json b/package.json index f2e720baeffa..ac971666cfdf 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "jasmine-reporters": "^2.2.0", "jest-junit": "^6.0.1", "jest-silent-reporter": "^0.1.1", + "jest-snapshot-serializer-raw": "^1.1.0", "jquery": "^3.2.1", "karma": "^3.1.4", "karma-browserify": "^6.0.0", diff --git a/packages/jest-mock/src/__tests__/jest_mock.test.js b/packages/jest-mock/src/__tests__/jest_mock.test.js index 432023561f83..bd38cb281806 100644 --- a/packages/jest-mock/src/__tests__/jest_mock.test.js +++ b/packages/jest-mock/src/__tests__/jest_mock.test.js @@ -70,7 +70,7 @@ describe('moduleMocker', () => { expect(mock.name).toBe('foo'); }); - it('escapes illegal characters in function name property', () => { + it('fixes illegal function name properties', () => { function getMockFnWithOriginalName(name) { const fn = () => {}; Object.defineProperty(fn, 'name', {value: name}); @@ -78,21 +78,12 @@ describe('moduleMocker', () => { return moduleMocker.generateFromMetadata(moduleMocker.getMetadata(fn)); } - expect( - getMockFnWithOriginalName('foo-bar').name === 'foo$bar', - ).toBeTruthy(); - expect( - getMockFnWithOriginalName('foo-bar-2').name === 'foo$bar$2', - ).toBeTruthy(); - expect( - getMockFnWithOriginalName('foo-bar-3').name === 'foo$bar$3', - ).toBeTruthy(); - expect( - getMockFnWithOriginalName('foo/bar').name === 'foo$bar', - ).toBeTruthy(); - expect( - getMockFnWithOriginalName('foo𠮷bar').name === 'foo𠮷bar', - ).toBeTruthy(); + expect(getMockFnWithOriginalName('1').name).toBe('$1'); + expect(getMockFnWithOriginalName('foo-bar').name).toBe('foo$bar'); + expect(getMockFnWithOriginalName('foo-bar-2').name).toBe('foo$bar$2'); + expect(getMockFnWithOriginalName('foo-bar-3').name).toBe('foo$bar$3'); + expect(getMockFnWithOriginalName('foo/bar').name).toBe('foo$bar'); + expect(getMockFnWithOriginalName('foo𠮷bar').name).toBe('foo𠮷bar'); }); it('special cases the mockConstructor name', () => { @@ -348,6 +339,18 @@ describe('moduleMocker', () => { ).not.toThrow(); }); + it('mocks functions with numeric names', () => { + const obj = { + 1: () => {}, + }; + + const objMock = moduleMocker.generateFromMetadata( + moduleMocker.getMetadata(obj), + ); + + expect(typeof objMock[1]).toBe('function'); + }); + describe('mocked functions', () => { it('tracks calls to mocks', () => { const fn = moduleMocker.fn(); diff --git a/packages/jest-mock/src/index.js b/packages/jest-mock/src/index.js index de67933b542f..9a95f5d9f2e1 100644 --- a/packages/jest-mock/src/index.js +++ b/packages/jest-mock/src/index.js @@ -73,56 +73,56 @@ const FUNCTION_NAME_RESERVED_REPLACE = new RegExp( 'g', ); -const RESERVED_KEYWORDS = Object.assign(Object.create(null), { - arguments: true, - await: true, - break: true, - case: true, - catch: true, - class: true, - const: true, - continue: true, - debugger: true, - default: true, - delete: true, - do: true, - else: true, - enum: true, - eval: true, - export: true, - extends: true, - false: true, - finally: true, - for: true, - function: true, - if: true, - implements: true, - import: true, - in: true, - instanceof: true, - interface: true, - let: true, - new: true, - null: true, - package: true, - private: true, - protected: true, - public: true, - return: true, - static: true, - super: true, - switch: true, - this: true, - throw: true, - true: true, - try: true, - typeof: true, - var: true, - void: true, - while: true, - with: true, - yield: true, -}); +const RESERVED_KEYWORDS = new Set([ + 'arguments', + 'await', + 'break', + 'case', + 'catch', + 'class', + 'const', + 'continue', + 'debugger', + 'default', + 'delete', + 'do', + 'else', + 'enum', + 'eval', + 'export', + 'extends', + 'false', + 'finally', + 'for', + 'function', + 'if', + 'implements', + 'import', + 'in', + 'instanceof', + 'interface', + 'let', + 'new', + 'null', + 'package', + 'private', + 'protected', + 'public', + 'return', + 'static', + 'super', + 'switch', + 'this', + 'throw', + 'true', + 'try', + 'typeof', + 'var', + 'void', + 'while', + 'with', + 'yield', +]); function matchArity(fn: any, length: number): any { let mockConstructor; @@ -623,9 +623,13 @@ class ModuleMockerClass { return mockConstructor; } - // It's a syntax error to define functions with a reserved keyword - // as name. - if (RESERVED_KEYWORDS[name]) { + if ( + // It's a syntax error to define functions with a reserved keyword + // as name. + RESERVED_KEYWORDS.has(name) || + // It's also a syntax error to define functions with a name that starts with a number + /^\d/.test(name) + ) { name = '$' + name; } @@ -684,7 +688,7 @@ class ModuleMockerClass { /** * @see README.md - * @param metadata Metadata for the mock in the schema returned by the + * @param _metadata Metadata for the mock in the schema returned by the * getMetadata method of this module. */ generateFromMetadata(_metadata: MockFunctionMetadata): Mock { diff --git a/website/blog/2017-12-18-jest-22.md b/website/blog/2017-12-18-jest-22.md index b7b11813e4cc..cb50df774577 100644 --- a/website/blog/2017-12-18-jest-22.md +++ b/website/blog/2017-12-18-jest-22.md @@ -7,6 +7,8 @@ authorFBID: 100003004880942 Today we are announcing a new major version of Jest which refines almost all parts of Jest to provide a more solid testing foundation. Together with the Jest community we made a number of changes across the board that will help you get more out of Jest. We are also graduating the custom runners feature out of the experimental stage and added a new package, `jest-worker`, for parallelizing work across multiple processes. We have compiled a list of highlights below but make sure to check out the (as always) [massive changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md). + + ## Good bye Node 4 & welcome JSDOM 11 With this release we are dropping support for Node 4, mainly because one of our main dependencies, JSDOM, ended their support. Jest now comes out of the box with JSDOM 11 which features better support for SVGs, `requestAnimationFrame`, `URL` and `URLSearchParams` built in, and [much more](https://github.com/tmpvar/jsdom/blob/master/Changelog.md). diff --git a/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md b/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md index db924df35359..292dbac3426b 100644 --- a/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md +++ b/website/blog/2018-05-29-jest-23-blazing-fast-delightful-testing.md @@ -11,6 +11,8 @@ We would also like to welcome both [Babel](https://babeljs.io/) and [Webpack](ht Here's are some of the Jest 23 highlights and breaking changes. + + For a full list see the [changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md). ## Interactive Snapshot Mode diff --git a/website/blog/2018-06-27-supporting-jest-open-source.md b/website/blog/2018-06-27-supporting-jest-open-source.md index efb7b4bb4128..2935b0f55f52 100644 --- a/website/blog/2018-06-27-supporting-jest-open-source.md +++ b/website/blog/2018-06-27-supporting-jest-open-source.md @@ -15,6 +15,8 @@ At the Jest Summit we announced the Jest Open Collective. This is our way to hel In this post we'll outline what the Jest Open Collective is, the structure, and the goals we have. + + # The Jest Open Collective ![Banner image for Jest Open Collective](/img/blog/collective.png) diff --git a/website/versioned_docs/version-22.0/Configuration.md b/website/versioned_docs/version-22.0/Configuration.md index aad44be11883..bf21f633b80c 100644 --- a/website/versioned_docs/version-22.0/Configuration.md +++ b/website/versioned_docs/version-22.0/Configuration.md @@ -276,9 +276,9 @@ return { Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-22.1/Configuration.md b/website/versioned_docs/version-22.1/Configuration.md index ce6b83b56c99..9172950c52db 100644 --- a/website/versioned_docs/version-22.1/Configuration.md +++ b/website/versioned_docs/version-22.1/Configuration.md @@ -274,9 +274,9 @@ return { Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-22.2/Configuration.md b/website/versioned_docs/version-22.2/Configuration.md index 77c9dc204d80..ec9ddef9086b 100644 --- a/website/versioned_docs/version-22.2/Configuration.md +++ b/website/versioned_docs/version-22.2/Configuration.md @@ -274,9 +274,9 @@ return { Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-22.3/Configuration.md b/website/versioned_docs/version-22.3/Configuration.md index 0a05221fa957..348c22e76aec 100644 --- a/website/versioned_docs/version-22.3/Configuration.md +++ b/website/versioned_docs/version-22.3/Configuration.md @@ -259,9 +259,9 @@ This option allows the use of a custom global teardown module which exports an a Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-22.4/Configuration.md b/website/versioned_docs/version-22.4/Configuration.md index 85eed4fa1add..f7cf200d878a 100644 --- a/website/versioned_docs/version-22.4/Configuration.md +++ b/website/versioned_docs/version-22.4/Configuration.md @@ -290,9 +290,9 @@ This option allows the use of a custom global teardown module which exports an a Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-23.0/Configuration.md b/website/versioned_docs/version-23.0/Configuration.md index 25da9f689a8a..33032db580b7 100644 --- a/website/versioned_docs/version-23.0/Configuration.md +++ b/website/versioned_docs/version-23.0/Configuration.md @@ -310,9 +310,9 @@ This option allows the use of a custom global teardown module which exports an a Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-23.1/Configuration.md b/website/versioned_docs/version-23.1/Configuration.md index 7b21588fc390..b4f97e2e514a 100644 --- a/website/versioned_docs/version-23.1/Configuration.md +++ b/website/versioned_docs/version-23.1/Configuration.md @@ -310,9 +310,9 @@ This option allows the use of a custom global teardown module which exports an a Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleDirectories` [array] diff --git a/website/versioned_docs/version-23.2/Configuration.md b/website/versioned_docs/version-23.2/Configuration.md index 6e04c635ce57..9ce18c46868d 100644 --- a/website/versioned_docs/version-23.2/Configuration.md +++ b/website/versioned_docs/version-23.2/Configuration.md @@ -322,9 +322,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleNameMapper` [object] diff --git a/website/versioned_docs/version-23.3/Configuration.md b/website/versioned_docs/version-23.3/Configuration.md index edaa23b9adbc..e86a11489eee 100644 --- a/website/versioned_docs/version-23.3/Configuration.md +++ b/website/versioned_docs/version-23.3/Configuration.md @@ -322,9 +322,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleNameMapper` [object] diff --git a/website/versioned_docs/version-23.4/Configuration.md b/website/versioned_docs/version-23.4/Configuration.md index c7e7a0557e73..bb7f67a5c07b 100644 --- a/website/versioned_docs/version-23.4/Configuration.md +++ b/website/versioned_docs/version-23.4/Configuration.md @@ -322,9 +322,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleNameMapper` [object] diff --git a/website/versioned_docs/version-23.5/Configuration.md b/website/versioned_docs/version-23.5/Configuration.md index ce8bb1ae41ae..f0b8e299b636 100644 --- a/website/versioned_docs/version-23.5/Configuration.md +++ b/website/versioned_docs/version-23.5/Configuration.md @@ -340,9 +340,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleNameMapper` [object] diff --git a/website/versioned_docs/version-23.6/Configuration.md b/website/versioned_docs/version-23.6/Configuration.md index a687b04524e4..08de1bab0b95 100644 --- a/website/versioned_docs/version-23.6/Configuration.md +++ b/website/versioned_docs/version-23.6/Configuration.md @@ -340,9 +340,9 @@ An array of directory names to be searched recursively up from the requiring mod Default: `["js", "json", "jsx", "node"]` -An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for. +An array of file extensions your modules use. If you require modules without specifying a file extension, these are the extensions Jest will look for, in left-to-right order. -If you are using TypeScript this should be `["js", "jsx", "json", "ts", "tsx"]`, check [ts-jest's documentation](https://github.com/kulshekhar/ts-jest). +If you are using TypeScript, you will want to add `"ts"` and/or `"tsx"` to the above default. Where you place these is up to you - we recommend placing the extensions most commonly used in your project on the left. ### `moduleNameMapper` [object] diff --git a/yarn.lock b/yarn.lock index dae900532674..8a4e188212b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7268,6 +7268,11 @@ jest-silent-reporter@^0.1.1: chalk "^2.3.1" jest-util "^23.0.0" +jest-snapshot-serializer-raw@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jest-snapshot-serializer-raw/-/jest-snapshot-serializer-raw-1.1.0.tgz#1d7f09c02f3dbbc3ae70b5b7598fb2f45e37d6c8" + integrity sha512-OL3bXRCnSn7Kur3YTGYj+A3Hwh2eyb5QL5VLQ9OSsPBOva7r3sCB0Jf1rOT/KN3ypzH42hrkDz96lpbiMo+AlQ== + jpegtran-bin@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/jpegtran-bin/-/jpegtran-bin-3.2.0.tgz#f60ecf4ae999c0bdad2e9fbcdf2b6f0981e7a29b"