Skip to content

Commit

Permalink
Ignore generated folders for test coverage
Browse files Browse the repository at this point in the history
This is a quick solution for ignoring coverage for generated folders while we continue to iterate on fusionjs#532.
  • Loading branch information
KevinGrandon committed Oct 26, 2018
1 parent 419b0c6 commit 85cdb79
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
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();
}

0 comments on commit 85cdb79

Please sign in to comment.