Skip to content

Commit

Permalink
coverage?
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 27, 2018
1 parent 2bca3b6 commit 521cd3a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 47 deletions.
10 changes: 5 additions & 5 deletions e2e/__tests__/__snapshots__/coverage_remapping.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Object {
"0": Object {
"decl": Object {
"end": Object {
"column": 28,
"column": 29,
"line": 3,
},
"start": Object {
Expand All @@ -206,7 +206,7 @@ Object {
"1": Object {
"decl": Object {
"end": Object {
"column": 35,
"column": 36,
"line": 7,
},
"start": Object {
Expand All @@ -229,7 +229,7 @@ Object {
"2": Object {
"decl": Object {
"end": Object {
"column": 48,
"column": 49,
"line": 7,
},
"start": Object {
Expand Down Expand Up @@ -314,7 +314,7 @@ Object {
},
"5": Object {
"end": Object {
"column": 40,
"column": 43,
"line": 7,
},
"start": Object {
Expand All @@ -324,7 +324,7 @@ Object {
},
"6": Object {
"end": Object {
"column": 53,
"column": 54,
"line": 7,
},
"start": Object {
Expand Down
20 changes: 10 additions & 10 deletions e2e/__tests__/__snapshots__/coverage_report.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ 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</> | </> |
coverage-report </> | 41.18</> | 0</> | 25</> | 42.86</> | </> |
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</> |
coverage-report/cached-duplicates/a</> | 100</> | 100</> | 100</> | 100</> | </> |
Identical.js </> | 100</> | 100</> | 100</> | 100</> | </> |
coverage-report/cached-duplicates/b</> | 100</> | 100</> | 100</> | 100</> | </> |
Identical.js </> | 100</> | 100</> | 100</> | 100</> | </> |
All files | 56.52 | 0 | 50 | 55.56 | |
coverage-report | 41.18 | 0 | 25 | 42.86 | |
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 |
coverage-report/cached-duplicates/a | 100 | 100 | 100 | 100 | |
Identical.js | 100 | 100 | 100 | 100 | |
coverage-report/cached-duplicates/b | 100 | 100 | 100 | 100 | |
Identical.js | 100 | 100 | 100 | 100 | |
-------------------------------------|----------|----------|----------|----------|-------------------|"
`;

Expand Down
11 changes: 2 additions & 9 deletions e2e/__tests__/coverage_report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', () => {
Expand Down
3 changes: 3 additions & 0 deletions e2e/coverage-report/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-flow'],
};
1 change: 1 addition & 0 deletions e2e/coverage-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"collectCoverageFrom": [
"**/*.js",
"!setup.js",
"!babel.config.js",
"!**/node_modules/**",
"!**/coverage/**"
],
Expand Down
5 changes: 2 additions & 3 deletions e2e/coverage-transform-instrumented/Preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

const {transformSync: babelTransform} = require('@babel/core');
const {default: babelIstanbulPlugin} = require('babel-plugin-istanbul');
// This is imported from this repo
const jestPreset = require.resolve('babel-preset-jest');

const options = {
Expand All @@ -33,8 +34,6 @@ module.exports = {
];
}

const transformResult = babelTransform(src, options);

return transformResult ? transformResult.code : src;
return babelTransform(src, options) || src;
},
};
3 changes: 1 addition & 2 deletions e2e/coverage-transform-instrumented/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-plugin-istanbul": "^5.1.0",
"babel-preset-jest": "^23.2.0"
"babel-plugin-istanbul": "^5.1.0"
}
}
18 changes: 0 additions & 18 deletions e2e/coverage-transform-instrumented/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -604,24 +604,6 @@ babel-plugin-istanbul@^5.1.0:
istanbul-lib-instrument "^3.0.0"
test-exclude "^5.0.0"

babel-plugin-jest-hoist@^23.2.0:
version "23.2.0"
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167"
integrity sha1-5h+uBaHKiAGq3uV6bWa4zvr0QWc=

babel-plugin-syntax-object-rest-spread@^6.13.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
integrity sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=

babel-preset-jest@^23.2.0:
version "23.2.0"
resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-23.2.0.tgz#8ec7a03a138f001a1a8fb1e8113652bf1a55da46"
integrity sha1-jsegOhOPABoaj7HoETZSvxpV2kY=
dependencies:
babel-plugin-jest-hoist "^23.2.0"
babel-plugin-syntax-object-rest-spread "^6.13.0"

balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
Expand Down

0 comments on commit 521cd3a

Please sign in to comment.