Skip to content

Commit

Permalink
Correct summary message for flag --findRelatedTests. (#4309)
Browse files Browse the repository at this point in the history
* fixes #4247
	* added tests for findRelatedTests summary message
  • Loading branch information
tushardhole authored and aaronabramov committed Aug 21, 2017
1 parent 90b5c05 commit cb6bcba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions integration_tests/__tests__/find_related_files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ test('runs tests related to filename', () => {

const {stderr} = runJest(DIR, ['--findRelatedTests', 'a.js']);
expect(stderr).toMatch('PASS __tests__/test.test.js');

const summaryMsg = 'Ran all test suites related to files matching /a.js/i.';
expect(stderr).toMatch(summaryMsg);
});
16 changes: 12 additions & 4 deletions packages/jest-cli/src/reporters/summary_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,20 @@ class SummaryReporter extends BaseReporter {
}

_getTestSummary(contexts: Set<Context>, globalConfig: GlobalConfig) {
const getMatchingTestsInfo = () => {
const prefix = globalConfig.findRelatedTests
? ' related to files matching '
: ' matching ';

return (
chalk.dim(prefix) +
testPathPatternToRegExp(globalConfig.testPathPattern).toString()
);
};

const testInfo = globalConfig.onlyChanged
? chalk.dim(' related to changed files')
: globalConfig.testPathPattern
? chalk.dim(' matching ') +
testPathPatternToRegExp(globalConfig.testPathPattern).toString()
: '';
: globalConfig.testPathPattern ? getMatchingTestsInfo() : '';

const nameInfo = globalConfig.testNamePattern
? chalk.dim(' with tests matching ') + `"${globalConfig.testNamePattern}"`
Expand Down

0 comments on commit cb6bcba

Please sign in to comment.