UNPKG

2.57 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = getNoTestFoundVerbose;
7
8function _chalk() {
9 const data = _interopRequireDefault(require('chalk'));
10
11 _chalk = function () {
12 return data;
13 };
14
15 return data;
16}
17
18var _pluralize = _interopRequireDefault(require('./pluralize'));
19
20function _interopRequireDefault(obj) {
21 return obj && obj.__esModule ? obj : {default: obj};
22}
23
24/**
25 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
26 *
27 * This source code is licensed under the MIT license found in the
28 * LICENSE file in the root directory of this source tree.
29 */
30function getNoTestFoundVerbose(testRunData, globalConfig) {
31 const individualResults = testRunData.map(testRun => {
32 const stats = testRun.matches.stats || {};
33 const config = testRun.context.config;
34 const statsMessage = Object.keys(stats)
35 .map(key => {
36 if (key === 'roots' && config.roots.length === 1) {
37 return null;
38 }
39
40 const value = config[key];
41
42 if (value) {
43 const valueAsString = Array.isArray(value)
44 ? value.join(', ')
45 : String(value);
46 const matches = (0, _pluralize.default)(
47 'match',
48 stats[key] || 0,
49 'es'
50 );
51 return ` ${key}: ${_chalk().default.yellow(
52 valueAsString
53 )} - ${matches}`;
54 }
55
56 return null;
57 })
58 .filter(line => line)
59 .join('\n');
60 return testRun.matches.total
61 ? `In ${_chalk().default.bold(config.rootDir)}\n` +
62 ` ${(0, _pluralize.default)(
63 'file',
64 testRun.matches.total || 0,
65 's'
66 )} checked.\n` +
67 statsMessage
68 : `No files found in ${config.rootDir}.\n` +
69 `Make sure Jest's configuration does not exclude this directory.` +
70 `\nTo set up Jest, make sure a package.json file exists.\n` +
71 `Jest Documentation: ` +
72 `facebook.github.io/jest/docs/configuration.html`;
73 });
74 let dataMessage;
75
76 if (globalConfig.runTestsByPath) {
77 dataMessage = `Files: ${globalConfig.nonFlagArgs
78 .map(p => `"${p}"`)
79 .join(', ')}`;
80 } else {
81 dataMessage = `Pattern: ${_chalk().default.yellow(
82 globalConfig.testPathPattern
83 )} - 0 matches`;
84 }
85
86 return (
87 _chalk().default.bold('No tests found, exiting with code 1') +
88 '\n' +
89 'Run with `--passWithNoTests` to exit with code 0' +
90 '\n' +
91 individualResults.join('\n') +
92 '\n' +
93 dataMessage
94 );
95}