1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.makeInvalidTransformerError =
|
7 | exports.makeInvalidSyncTransformerError =
|
8 | exports.makeInvalidSourceMapWarning =
|
9 | exports.makeInvalidReturnValueError =
|
10 | void 0;
|
11 | function _chalk() {
|
12 | const data = _interopRequireDefault(require('chalk'));
|
13 | _chalk = function () {
|
14 | return data;
|
15 | };
|
16 | return data;
|
17 | }
|
18 | function _slash() {
|
19 | const data = _interopRequireDefault(require('slash'));
|
20 | _slash = function () {
|
21 | return data;
|
22 | };
|
23 | return data;
|
24 | }
|
25 | function _interopRequireDefault(obj) {
|
26 | return obj && obj.__esModule ? obj : {default: obj};
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | const BULLET = '\u25cf ';
|
36 | const DOCUMENTATION_NOTE = ` ${_chalk().default.bold(
|
37 | 'Code Transformation Documentation:'
|
38 | )}
|
39 | https://jestjs.io/docs/code-transformation
|
40 | `;
|
41 | const UPGRADE_NOTE = ` ${_chalk().default.bold(
|
42 | 'This error may be caused by a breaking change in Jest 28:'
|
43 | )}
|
44 | https://jestjs.io/docs/28.x/upgrading-to-jest28#transformer
|
45 | `;
|
46 | const makeInvalidReturnValueError = transformPath =>
|
47 | _chalk().default.red(
|
48 | [
|
49 | _chalk().default.bold(`${BULLET}Invalid return value:`),
|
50 | ' `process()` or/and `processAsync()` method of code transformer found at ',
|
51 | ` "${(0, _slash().default)(transformPath)}" `,
|
52 | ' should return an object or a Promise resolving to an object. The object ',
|
53 | ' must have `code` property with a string of processed code.',
|
54 | ''
|
55 | ].join('\n') +
|
56 | UPGRADE_NOTE +
|
57 | DOCUMENTATION_NOTE
|
58 | );
|
59 | exports.makeInvalidReturnValueError = makeInvalidReturnValueError;
|
60 | const makeInvalidSourceMapWarning = (filename, transformPath) =>
|
61 | _chalk().default.yellow(
|
62 | [
|
63 | _chalk().default.bold(`${BULLET}Invalid source map:`),
|
64 | ` The source map for "${(0, _slash().default)(
|
65 | filename
|
66 | )}" returned by "${(0, _slash().default)(transformPath)}" is invalid.`,
|
67 | ' Proceeding without source mapping for that file.'
|
68 | ].join('\n')
|
69 | );
|
70 | exports.makeInvalidSourceMapWarning = makeInvalidSourceMapWarning;
|
71 | const makeInvalidSyncTransformerError = transformPath =>
|
72 | _chalk().default.red(
|
73 | [
|
74 | _chalk().default.bold(`${BULLET}Invalid synchronous transformer module:`),
|
75 | ` "${(0, _slash().default)(
|
76 | transformPath
|
77 | )}" specified in the "transform" object of Jest configuration`,
|
78 | ' must export a `process` function.',
|
79 | ''
|
80 | ].join('\n') + DOCUMENTATION_NOTE
|
81 | );
|
82 | exports.makeInvalidSyncTransformerError = makeInvalidSyncTransformerError;
|
83 | const makeInvalidTransformerError = transformPath =>
|
84 | _chalk().default.red(
|
85 | [
|
86 | _chalk().default.bold(`${BULLET}Invalid transformer module:`),
|
87 | ` "${(0, _slash().default)(
|
88 | transformPath
|
89 | )}" specified in the "transform" object of Jest configuration`,
|
90 | ' must export a `process` or `processAsync` or `createTransformer` function.',
|
91 | ''
|
92 | ].join('\n') + DOCUMENTATION_NOTE
|
93 | );
|
94 | exports.makeInvalidTransformerError = makeInvalidTransformerError;
|