runtimeErrorsAndWarnings.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.makeInvalidTransformerError =
  6. exports.makeInvalidSyncTransformerError =
  7. exports.makeInvalidSourceMapWarning =
  8. exports.makeInvalidReturnValueError =
  9. void 0;
  10. function _chalk() {
  11. const data = _interopRequireDefault(require('chalk'));
  12. _chalk = function () {
  13. return data;
  14. };
  15. return data;
  16. }
  17. function _slash() {
  18. const data = _interopRequireDefault(require('slash'));
  19. _slash = function () {
  20. return data;
  21. };
  22. return data;
  23. }
  24. function _interopRequireDefault(obj) {
  25. return obj && obj.__esModule ? obj : {default: obj};
  26. }
  27. /**
  28. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  29. *
  30. * This source code is licensed under the MIT license found in the
  31. * LICENSE file in the root directory of this source tree.
  32. */
  33. const BULLET = '\u25cf ';
  34. const DOCUMENTATION_NOTE = ` ${_chalk().default.bold(
  35. 'Code Transformation Documentation:'
  36. )}
  37. https://jestjs.io/docs/code-transformation
  38. `;
  39. const makeInvalidReturnValueError = () =>
  40. _chalk().default.red(
  41. [
  42. _chalk().default.bold(BULLET + 'Invalid return value:'),
  43. " Code transformer's `process` function must return a string or an object",
  44. ' with `code` key containing a string. If `processAsync` function is implemented,',
  45. ' it must return a Promise resolving to one of these values.',
  46. ''
  47. ].join('\n') + DOCUMENTATION_NOTE
  48. );
  49. exports.makeInvalidReturnValueError = makeInvalidReturnValueError;
  50. const makeInvalidSourceMapWarning = (filename, transformPath) =>
  51. _chalk().default.yellow(
  52. [
  53. _chalk().default.bold(BULLET + 'Invalid source map:'),
  54. ` The source map for "${(0, _slash().default)(
  55. filename
  56. )}" returned by "${(0, _slash().default)(transformPath)}" is invalid.`,
  57. ' Proceeding without source mapping for that file.'
  58. ].join('\n')
  59. );
  60. exports.makeInvalidSourceMapWarning = makeInvalidSourceMapWarning;
  61. const makeInvalidSyncTransformerError = transformPath =>
  62. _chalk().default.red(
  63. [
  64. _chalk().default.bold(BULLET + 'Invalid synchronous transformer module:'),
  65. ` "${(0, _slash().default)(
  66. transformPath
  67. )}" specified in the "transform" object of Jest configuration`,
  68. ' must export a `process` function.',
  69. ''
  70. ].join('\n') + DOCUMENTATION_NOTE
  71. );
  72. exports.makeInvalidSyncTransformerError = makeInvalidSyncTransformerError;
  73. const makeInvalidTransformerError = transformPath =>
  74. _chalk().default.red(
  75. [
  76. _chalk().default.bold(BULLET + 'Invalid transformer module:'),
  77. ` "${(0, _slash().default)(
  78. transformPath
  79. )}" specified in the "transform" object of Jest configuration`,
  80. ' must export a `process` or `processAsync` or `createTransformer` function.',
  81. ''
  82. ].join('\n') + DOCUMENTATION_NOTE
  83. );
  84. exports.makeInvalidTransformerError = makeInvalidTransformerError;