1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = getNoTestFoundVerbose;
|
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 getNoTestFoundVerbose(testRunData, globalConfig, willExitWith0) {
|
32 | const individualResults = testRunData.map(testRun => {
|
33 | const stats = testRun.matches.stats || {};
|
34 | const config = testRun.context.config;
|
35 | const statsMessage = Object.keys(stats)
|
36 | .map(key => {
|
37 | if (key === 'roots' && config.roots.length === 1) {
|
38 | return null;
|
39 | }
|
40 | const value = config[key];
|
41 | if (value) {
|
42 | const valueAsString = Array.isArray(value)
|
43 | ? value.join(', ')
|
44 | : String(value);
|
45 | const matches = (0, _jestUtil().pluralize)(
|
46 | 'match',
|
47 | stats[key] || 0,
|
48 | 'es'
|
49 | );
|
50 | return ` ${key}: ${_chalk().default.yellow(
|
51 | valueAsString
|
52 | )} - ${matches}`;
|
53 | }
|
54 | return null;
|
55 | })
|
56 | .filter(line => line)
|
57 | .join('\n');
|
58 | return testRun.matches.total
|
59 | ? `In ${_chalk().default.bold(config.rootDir)}\n` +
|
60 | ` ${(0, _jestUtil().pluralize)(
|
61 | 'file',
|
62 | testRun.matches.total || 0,
|
63 | 's'
|
64 | )} checked.\n${statsMessage}`
|
65 | : `No files found in ${config.rootDir}.\n` +
|
66 | "Make sure Jest's configuration does not exclude this directory." +
|
67 | '\nTo set up Jest, make sure a package.json file exists.\n' +
|
68 | 'Jest Documentation: ' +
|
69 | 'https://jestjs.io/docs/configuration';
|
70 | });
|
71 | let dataMessage;
|
72 | if (globalConfig.runTestsByPath) {
|
73 | dataMessage = `Files: ${globalConfig.nonFlagArgs
|
74 | .map(p => `"${p}"`)
|
75 | .join(', ')}`;
|
76 | } else {
|
77 | dataMessage = `Pattern: ${_chalk().default.yellow(
|
78 | globalConfig.testPathPattern
|
79 | )} - 0 matches`;
|
80 | }
|
81 | if (willExitWith0) {
|
82 | return `${_chalk().default.bold(
|
83 | 'No tests found, exiting with code 0'
|
84 | )}\n${individualResults.join('\n')}\n${dataMessage}`;
|
85 | }
|
86 | return (
|
87 | `${_chalk().default.bold('No tests found, exiting with code 1')}\n` +
|
88 | 'Run with `--passWithNoTests` to exit with code 0' +
|
89 | `\n${individualResults.join('\n')}\n${dataMessage}`
|
90 | );
|
91 | }
|