Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add test to reproduce #6462
  • Loading branch information
stipsan committed Jul 22, 2018
commit 3ce345b9be783f3ef4a81ae42ef026d088e684b5
24 changes: 24 additions & 0 deletions e2e/__tests__/__snapshots__/find_related_files.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`--findRelatedTests flag coverage configuration is applied correctly 1`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
Ran all test suites related to files matching /a.js/i."
`;

exports[`--findRelatedTests flag coverage configuration is applied correctly 2`] = `
"

PASS __tests__/a.test.js
✓ 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
Tests: 2 passed, 2 total
Expand Down
39 changes: 39 additions & 0 deletions e2e/__tests__/find_related_files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,43 @@ describe('--findRelatedTests flag', () => {
// coverage should be collected only for a.js
expect(stdout).toMatchSnapshot();
});

test('coverage configuration is applied correctly', () => {
writeFiles(DIR, {
'.watchmanconfig': '',
'__tests__/a.test.js': `
require('../a');
test('a', () => expect(1).toBe(1));
`,
'a.js': 'module.exports = {}',
'b.js': 'module.exports = {}',
'package.json': JSON.stringify({
jest: {
collectCoverage: true,
collectCoverageFrom: ['a.js', '!b.js'],
testEnvironment: 'node',
},
}),
});

const {stdout, stderr} = runJest(DIR, [
'--findRelatedTests',
'a.js',
'b.js',
]);
const {summary, rest} = extractSummary(stderr);
expect(summary).toMatchSnapshot();
expect(
rest
.split('\n')
.map(s => s.trim())
.sort()
.join('\n'),
).toMatchSnapshot();
expect(stdout).toMatchSnapshot();

// Only a.js should be in the report
const summaryMsg = 'Ran all test suites related to files matching /a.js/i.';
expect(stderr).toMatch(summaryMsg);
});
});