1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = getNoTestFound;
|
7 | function _chalk() {
|
8 | const data = _interopRequireDefault(require('chalk'));
|
9 | _chalk = function () {
|
10 | return data;
|
11 | };
|
12 | return data;
|
13 | }
|
14 | function _jestUtil() {
|
15 | const data = require('jest-util');
|
16 | _jestUtil = function () {
|
17 | return data;
|
18 | };
|
19 | return data;
|
20 | }
|
21 | function _interopRequireDefault(obj) {
|
22 | return obj && obj.__esModule ? obj : {default: obj};
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | function getNoTestFound(testRunData, globalConfig, willExitWith0) {
|
32 | const testFiles = testRunData.reduce(
|
33 | (current, testRun) => current + (testRun.matches.total || 0),
|
34 | 0
|
35 | );
|
36 | let dataMessage;
|
37 | if (globalConfig.runTestsByPath) {
|
38 | dataMessage = `Files: ${globalConfig.nonFlagArgs
|
39 | .map(p => `"${p}"`)
|
40 | .join(', ')}`;
|
41 | } else {
|
42 | dataMessage = `Pattern: ${_chalk().default.yellow(
|
43 | globalConfig.testPathPattern
|
44 | )} - 0 matches`;
|
45 | }
|
46 | if (willExitWith0) {
|
47 | return (
|
48 | `${_chalk().default.bold('No tests found, exiting with code 0')}\n` +
|
49 | `In ${_chalk().default.bold(globalConfig.rootDir)}` +
|
50 | '\n' +
|
51 | ` ${(0, _jestUtil().pluralize)(
|
52 | 'file',
|
53 | testFiles,
|
54 | 's'
|
55 | )} checked across ${(0, _jestUtil().pluralize)(
|
56 | 'project',
|
57 | testRunData.length,
|
58 | 's'
|
59 | )}. Run with \`--verbose\` for more details.` +
|
60 | `\n${dataMessage}`
|
61 | );
|
62 | }
|
63 | return (
|
64 | `${_chalk().default.bold('No tests found, exiting with code 1')}\n` +
|
65 | 'Run with `--passWithNoTests` to exit with code 0' +
|
66 | '\n' +
|
67 | `In ${_chalk().default.bold(globalConfig.rootDir)}` +
|
68 | '\n' +
|
69 | ` ${(0, _jestUtil().pluralize)(
|
70 | 'file',
|
71 | testFiles,
|
72 | 's'
|
73 | )} checked across ${(0, _jestUtil().pluralize)(
|
74 | 'project',
|
75 | testRunData.length,
|
76 | 's'
|
77 | )}. Run with \`--verbose\` for more details.` +
|
78 | `\n${dataMessage}`
|
79 | );
|
80 | }
|