getNoTestFound.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = getNoTestFound;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function _chalk() {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _pluralize = _interopRequireDefault(require('./pluralize'));
  14. function _interopRequireDefault(obj) {
  15. return obj && obj.__esModule ? obj : {default: obj};
  16. }
  17. /**
  18. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  19. *
  20. * This source code is licensed under the MIT license found in the
  21. * LICENSE file in the root directory of this source tree.
  22. */
  23. function getNoTestFound(testRunData, globalConfig) {
  24. const testFiles = testRunData.reduce(
  25. (current, testRun) => current + (testRun.matches.total || 0),
  26. 0
  27. );
  28. let dataMessage;
  29. if (globalConfig.runTestsByPath) {
  30. dataMessage = `Files: ${globalConfig.nonFlagArgs
  31. .map(p => `"${p}"`)
  32. .join(', ')}`;
  33. } else {
  34. dataMessage = `Pattern: ${_chalk().default.yellow(
  35. globalConfig.testPathPattern
  36. )} - 0 matches`;
  37. }
  38. return (
  39. _chalk().default.bold('No tests found, exiting with code 1') +
  40. '\n' +
  41. 'Run with `--passWithNoTests` to exit with code 0' +
  42. '\n' +
  43. `In ${_chalk().default.bold(globalConfig.rootDir)}` +
  44. '\n' +
  45. ` ${(0, _pluralize.default)('file', testFiles, 's')} checked across ${(0,
  46. _pluralize.default)(
  47. 'project',
  48. testRunData.length,
  49. 's'
  50. )}. Run with \`--verbose\` for more details.` +
  51. '\n' +
  52. dataMessage
  53. );
  54. }