-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Expand file tree
/
Copy pathget_no_test_found_verbose.js
More file actions
54 lines (49 loc) · 1.59 KB
/
get_no_test_found_verbose.js
File metadata and controls
54 lines (49 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import chalk from 'chalk';
import pluralize from './pluralize';
const getNoTestFoundVerbose = (testRunData, globalConfig): string => {
const individualResults = testRunData.map(testRun => {
const stats = testRun.matches.stats || {};
const config = testRun.context.config;
const statsMessage = Object.keys(stats)
.map(key => {
if (key === 'roots' && config.roots.length === 1) {
return null;
}
const value = config[key];
if (value) {
const matches = pluralize('match', stats[key], 'es');
return ` ${key}: ${chalk.yellow(value)} - ${matches}`;
}
return null;
})
.filter(line => line)
.join('\n');
return testRun.matches.total
? `In ${chalk.bold(config.rootDir)}\n` +
` ${pluralize('file', testRun.matches.total || 0, 's')} checked.\n` +
statsMessage
: `No files found in ${config.rootDir}.\n` +
`Make sure Jest's configuration does not exclude this directory.` +
`\nTo set up Jest, make sure a package.json file exists.\n` +
`Jest Documentation: ` +
`facebook.github.io/jest/docs/configuration.html`;
});
let dataMessage;
if (globalConfig.runTestsByPath) {
dataMessage = `Files: ${globalConfig.nonFlagArgs
.map(p => `"${p}"`)
.join(', ')}`;
} else {
dataMessage = `Pattern: ${chalk.yellow(
globalConfig.testPathPattern,
)} - 0 matches`;
}
return (
chalk.bold('No tests found') +
'\n' +
individualResults.join('\n') +
'\n' +
dataMessage
);
};
module.exports = getNoTestFoundVerbose;