1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _pEachSeries() {
|
9 | const data = _interopRequireDefault(require('p-each-series'));
|
10 |
|
11 | _pEachSeries = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _transform() {
|
19 | const data = require('@jest/transform');
|
20 |
|
21 | _transform = function () {
|
22 | return data;
|
23 | };
|
24 |
|
25 | return data;
|
26 | }
|
27 |
|
28 | function _jestUtil() {
|
29 | const data = require('jest-util');
|
30 |
|
31 | _jestUtil = function () {
|
32 | return data;
|
33 | };
|
34 |
|
35 | return data;
|
36 | }
|
37 |
|
38 | function _interopRequireDefault(obj) {
|
39 | return obj && obj.__esModule ? obj : {default: obj};
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | var _default = async ({allTests, globalConfig, moduleName}) => {
|
49 | const globalModulePaths = new Set(
|
50 | allTests.map(test => test.context.config[moduleName])
|
51 | );
|
52 |
|
53 | if (globalConfig[moduleName]) {
|
54 | globalModulePaths.add(globalConfig[moduleName]);
|
55 | }
|
56 |
|
57 | if (globalModulePaths.size > 0) {
|
58 | await (0, _pEachSeries().default)(
|
59 | Array.from(globalModulePaths),
|
60 | async modulePath => {
|
61 | if (!modulePath) {
|
62 | return;
|
63 | }
|
64 |
|
65 | const correctConfig = allTests.find(
|
66 | t => t.context.config[moduleName] === modulePath
|
67 | );
|
68 | const projectConfig = correctConfig
|
69 | ? correctConfig.context.config
|
70 | : allTests[0].context.config;
|
71 | const transformer = new (_transform().ScriptTransformer)(projectConfig);
|
72 | await transformer.requireAndTranspileModule(modulePath, async m => {
|
73 | const globalModule = (0, _jestUtil().interopRequireDefault)(m)
|
74 | .default;
|
75 |
|
76 | if (typeof globalModule !== 'function') {
|
77 | throw new TypeError(
|
78 | `${moduleName} file must export a function at ${modulePath}`
|
79 | );
|
80 | }
|
81 |
|
82 | await globalModule(globalConfig);
|
83 | });
|
84 | }
|
85 | );
|
86 | }
|
87 |
|
88 | return Promise.resolve();
|
89 | };
|
90 |
|
91 | exports.default = _default;
|