diff --git a/e2e/__tests__/__snapshots__/coverage_report.test.js.snap b/e2e/__tests__/__snapshots__/coverage_report.test.js.snap index e741fd69db6a..1d99531bccd9 100644 --- a/e2e/__tests__/__snapshots__/coverage_report.test.js.snap +++ b/e2e/__tests__/__snapshots__/coverage_report.test.js.snap @@ -72,12 +72,12 @@ exports[`outputs coverage report 1`] = ` "-------------------------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------------------------------|----------|----------|----------|----------|-------------------| -All files | 56.52 | 0 | 50 | 55.56 | | - coverage-report | 41.18 | 0 | 25 | 42.86 | | +All files | 59.09 | 0 | 50 | 58.82 | | + coverage-report | 43.75 | 0 | 25 | 46.15 | | OtherFile.js | 100 | 100 | 100 | 100 | | Sum.js | 85.71 | 100 | 50 | 100 | | SumDependency.js | 0 | 0 | 0 | 0 | 8,10,12 | - notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 8,15,16,17,19 | + notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 15,16,17,19 | coverage-report/cached-duplicates/a | 100 | 100 | 100 | 100 | | Identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | @@ -88,20 +88,20 @@ All files | 56.52 | 0 | 50 | 55.56 exports[`outputs coverage report when text and text-summary is requested 1`] = ` " =============================== Coverage summary =============================== -Statements : 56.52% ( 13/23 ) +Statements : 59.09% ( 13/22 ) Branches : 0% ( 0/4 ) Functions : 50% ( 3/6 ) -Lines : 55.56% ( 10/18 ) +Lines : 58.82% ( 10/17 ) ================================================================================ -------------------------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | -------------------------------------|----------|----------|----------|----------|-------------------| -All files | 56.52 | 0 | 50 | 55.56 | | - coverage-report | 41.18 | 0 | 25 | 42.86 | | +All files | 59.09 | 0 | 50 | 58.82 | | + coverage-report | 43.75 | 0 | 25 | 46.15 | | OtherFile.js | 100 | 100 | 100 | 100 | | Sum.js | 85.71 | 100 | 50 | 100 | | SumDependency.js | 0 | 0 | 0 | 0 | 8,10,12 | - notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 8,15,16,17,19 | + notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 15,16,17,19 | coverage-report/cached-duplicates/a | 100 | 100 | 100 | 100 | | Identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | @@ -113,12 +113,12 @@ 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 | | - coverage-report | 41.18 | 0 | 25 | 42.86 | | +All files | 59.09 | 0 | 50 | 58.82 | | + coverage-report | 43.75 | 0 | 25 | 46.15 | | OtherFile.js | 100 | 100 | 100 | 100 | | Sum.js | 85.71 | 100 | 50 | 100 | | SumDependency.js | 0 | 0 | 0 | 0 | 8,10,12 | - notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 8,15,16,17,19 | + notRequiredInTestSuite.js | 0 | 0 | 0 | 0 | 15,16,17,19 | coverage-report/cached-duplicates/a | 100 | 100 | 100 | 100 | | Identical.js | 100 | 100 | 100 | 100 | | coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | | @@ -129,9 +129,9 @@ All files | 56.52 | 0 | 50 | 55.56 exports[`outputs coverage report when text-summary is requested 1`] = ` " =============================== Coverage summary =============================== -Statements : 56.52% ( 13/23 ) +Statements : 59.09% ( 13/22 ) Branches : 0% ( 0/4 ) Functions : 50% ( 3/6 ) -Lines : 55.56% ( 10/18 ) +Lines : 58.82% ( 10/17 ) ================================================================================" `; diff --git a/e2e/__tests__/coverage_report.test.js b/e2e/__tests__/coverage_report.test.js index d12b0f2f7b3a..642c0031def5 100644 --- a/e2e/__tests__/coverage_report.test.js +++ b/e2e/__tests__/coverage_report.test.js @@ -19,7 +19,7 @@ test('outputs coverage report', () => { const {stdout, status} = runJest(DIR, ['--no-cache', '--coverage'], { stripAnsi: true, }); - const coverageDir = path.resolve(__dirname, '../coverage-report/coverage'); + const coverageDir = path.join(DIR, 'coverage'); // - the `setup.js` file is ignored and should not be in the coverage report. // - `SumDependency.js` is mocked and the real module is never required but @@ -99,14 +99,7 @@ test('outputs coverage report as json', () => { {stripAnsi: true}, ); expect(status).toBe(0); - - try { - JSON.parse(stdout); - } catch (err) { - throw new Error( - "Can't parse the JSON result from stdout. " + err.toString(), - ); - } + expect(() => JSON.parse(stdout)).not.toThrow(); }); test('outputs coverage report when text is requested', () => { diff --git a/e2e/coverage-report/babel.config.js b/e2e/coverage-report/babel.config.js new file mode 100644 index 000000000000..6869642766b4 --- /dev/null +++ b/e2e/coverage-report/babel.config.js @@ -0,0 +1,3 @@ +module.exports = { + presets: ['@babel/preset-flow'], +}; diff --git a/e2e/coverage-report/package.json b/e2e/coverage-report/package.json index a36cacf43a71..4ced9148e930 100644 --- a/e2e/coverage-report/package.json +++ b/e2e/coverage-report/package.json @@ -3,6 +3,7 @@ "collectCoverageFrom": [ "**/*.js", "!setup.js", + "!babel.config.js", "!**/node_modules/**", "!**/coverage/**" ],