Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Ignore generated folders for test coverage #592

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/jest/base-jest-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ module.exports = {
'!**/__integration__/**',
'!**/node_modules/**',
],
coveragePathIgnorePatterns: ['src/.*generated.*'],
testResultsProcessor: require.resolve('./results-processor.js'),
};
6 changes: 6 additions & 0 deletions test/cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,18 @@ test('`fusion test` coverage', async t => {

const cmd = `require('${runnerPath}').run('node ${runnerPath} ${args}')`;
const response = await exec(`node -e "${cmd}"`);

t.equal(countTests(response.stderr), 2, 'ran 2 tests');

// Look for something like coverage
t.ok(response.stdout.includes('Uncovered Line #s'));

// This file is outside of src and should not be included in coverage
t.ok(!response.stdout.includes('should-not-count-for-coverage.js'));

// Ignores generated files
t.ok(!response.stdout.includes('generated-file.js'));

t.end();
});

Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/test-jest-app/src/generated/generated-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flow
export default function() {}
5 changes: 4 additions & 1 deletion test/fixtures/test-jest-app/src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow
import {foo} from './foo.js';
import noopIgnoredCoverage from './generated/generated-file.js';

export default function () {
export default function() {
noopIgnoredCoverage();
return foo();
}