@modern-js/plugin-testing 2.0.0-beta.3 → 2.0.0-beta.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +159 -0
- package/dist/js/modern/base/config/index.js +29 -9
- package/dist/js/modern/base/config/patches/assetsModule.js +7 -7
- package/dist/js/modern/base/config/patches/filemock.js +4 -1
- package/dist/js/modern/base/config/patches/index.js +30 -7
- package/dist/js/modern/base/config/patches/transformer.js +13 -18
- package/dist/js/modern/base/config/resolver.js +20 -11
- package/dist/js/modern/base/config/testConfigOperator.js +29 -23
- package/dist/js/modern/base/config/transformer/babelTransformer.js +16 -8
- package/dist/js/modern/base/hook.js +10 -5
- package/dist/js/modern/base/index.js +14 -6
- package/dist/js/modern/base/runJest.js +73 -62
- package/dist/js/modern/base/utils.js +40 -23
- package/dist/js/modern/cli/bff/app.js +37 -12
- package/dist/js/modern/cli/bff/constant.js +4 -1
- package/dist/js/modern/cli/bff/index.js +95 -52
- package/dist/js/modern/cli/bff/mockAPI.js +79 -64
- package/dist/js/modern/cli/bff/setup.js +71 -34
- package/dist/js/modern/cli/bff/utils/index.js +31 -15
- package/dist/js/modern/cli/index.js +65 -30
- package/dist/js/modern/cli/test.js +53 -18
- package/dist/js/modern/constant.js +4 -1
- package/dist/js/modern/index.js +3 -3
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/runtime-testing/app.js +25 -14
- package/dist/js/modern/runtime-testing/base.js +7 -3
- package/dist/js/modern/runtime-testing/customRender.js +24 -10
- package/dist/js/modern/runtime-testing/index.js +1 -1
- package/dist/js/modern/runtime-testing/reduck.js +41 -19
- package/dist/js/modern/runtime-testing/request.js +4 -4
- package/dist/js/modern/runtime-testing/resolvePlugins.js +24 -8
- package/dist/js/node/base/config/index.js +62 -18
- package/dist/js/node/base/config/patches/assetsModule.js +34 -12
- package/dist/js/node/base/config/patches/filemock.js +24 -7
- package/dist/js/node/base/config/patches/index.js +54 -15
- package/dist/js/node/base/config/patches/transformer.js +42 -25
- package/dist/js/node/base/config/resolver.js +25 -10
- package/dist/js/node/base/config/testConfigOperator.js +51 -30
- package/dist/js/node/base/config/transformer/babelTransformer.js +42 -15
- package/dist/js/node/base/hook.js +34 -13
- package/dist/js/node/base/index.js +39 -62
- package/dist/js/node/base/runJest.js +104 -71
- package/dist/js/node/base/types/index.js +15 -0
- package/dist/js/node/base/utils.js +70 -34
- package/dist/js/node/cli/bff/app.js +64 -22
- package/dist/js/node/cli/bff/constant.js +26 -7
- package/dist/js/node/cli/bff/index.js +123 -65
- package/dist/js/node/cli/bff/mockAPI.js +103 -71
- package/dist/js/node/cli/bff/setup.js +71 -28
- package/dist/js/node/cli/bff/utils/index.js +57 -22
- package/dist/js/node/cli/index.js +92 -46
- package/dist/js/node/cli/test.js +81 -27
- package/dist/js/node/constant.js +26 -7
- package/dist/js/node/index.js +19 -18
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/runtime-testing/app.js +53 -25
- package/dist/js/node/runtime-testing/base.js +34 -32
- package/dist/js/node/runtime-testing/customRender.js +49 -18
- package/dist/js/node/runtime-testing/index.js +18 -27
- package/dist/js/node/runtime-testing/reduck.js +72 -31
- package/dist/js/node/runtime-testing/request.js +36 -13
- package/dist/js/node/runtime-testing/resolvePlugins.js +41 -12
- package/dist/js/treeshaking/base/config/index.js +150 -31
- package/dist/js/treeshaking/base/config/patches/assetsModule.js +9 -11
- package/dist/js/treeshaking/base/config/patches/filemock.js +2 -1
- package/dist/js/treeshaking/base/config/patches/index.js +221 -64
- package/dist/js/treeshaking/base/config/patches/transformer.js +34 -37
- package/dist/js/treeshaking/base/config/resolver.js +36 -13
- package/dist/js/treeshaking/base/config/testConfigOperator.js +120 -69
- package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +16 -10
- package/dist/js/treeshaking/base/hook.js +8 -7
- package/dist/js/treeshaking/base/index.js +7 -6
- package/dist/js/treeshaking/base/runJest.js +281 -164
- package/dist/js/treeshaking/base/types/index.js +1 -0
- package/dist/js/treeshaking/base/utils.js +72 -48
- package/dist/js/treeshaking/cli/bff/app.js +192 -68
- package/dist/js/treeshaking/cli/bff/constant.js +2 -1
- package/dist/js/treeshaking/cli/bff/index.js +291 -130
- package/dist/js/treeshaking/cli/bff/mockAPI.js +181 -91
- package/dist/js/treeshaking/cli/bff/setup.js +185 -59
- package/dist/js/treeshaking/cli/bff/utils/index.js +47 -21
- package/dist/js/treeshaking/cli/index.js +249 -108
- package/dist/js/treeshaking/cli/test.js +177 -44
- package/dist/js/treeshaking/constant.js +2 -1
- package/dist/js/treeshaking/index.js +3 -3
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/runtime-testing/app.js +85 -39
- package/dist/js/treeshaking/runtime-testing/base.js +4 -3
- package/dist/js/treeshaking/runtime-testing/customRender.js +38 -10
- package/dist/js/treeshaking/runtime-testing/index.js +1 -1
- package/dist/js/treeshaking/runtime-testing/reduck.js +85 -33
- package/dist/js/treeshaking/runtime-testing/request.js +49 -19
- package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +45 -14
- package/dist/types/base/config/index.d.ts +1 -0
- package/dist/types/base/config/patches/assetsModule.d.ts +1 -0
- package/dist/types/base/config/patches/filemock.d.ts +1 -0
- package/dist/types/base/config/patches/transformer.d.ts +1 -0
- package/dist/types/base/config/testConfigOperator.d.ts +2 -0
- package/dist/types/base/runJest.d.ts +2 -0
- package/dist/types/base/utils.d.ts +1 -0
- package/dist/types/cli/bff/index.d.ts +2 -0
- package/dist/types/cli/bff/mockAPI.d.ts +1 -0
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/runtime-testing/app.d.ts +3 -0
- package/dist/types/runtime-testing/customRender.d.ts +2 -0
- package/package.json +21 -25
@@ -1,28 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __export = (target, all) => {
|
20
|
+
for (var name in all)
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
22
|
+
};
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
25
|
+
for (let key of __getOwnPropNames(from))
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
28
|
+
}
|
29
|
+
return to;
|
30
|
+
};
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
32
|
+
var testConfigOperator_exports = {};
|
33
|
+
__export(testConfigOperator_exports, {
|
34
|
+
TestConfigOperator: () => TestConfigOperator
|
5
35
|
});
|
6
|
-
exports
|
7
|
-
var
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
10
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
36
|
+
module.exports = __toCommonJS(testConfigOperator_exports);
|
37
|
+
var import_lodash = require("@modern-js/utils/lodash");
|
11
38
|
class TestConfigOperator {
|
12
39
|
constructor(testConfig) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
_defineProperty(this, "defaultTestConfig", {
|
17
|
-
transformer: 'babel-jest'
|
18
|
-
});
|
40
|
+
this.defaultTestConfig = {
|
41
|
+
transformer: "babel-jest"
|
42
|
+
};
|
19
43
|
this._testConfig = testConfig;
|
20
44
|
this._jestConfig = {};
|
21
45
|
this.userJestConfig = testConfig.jest;
|
22
46
|
this.initial();
|
23
47
|
}
|
24
48
|
initial() {
|
25
|
-
this._testConfig = (0,
|
49
|
+
this._testConfig = (0, import_lodash.merge)({}, this.defaultTestConfig, this.testConfig);
|
26
50
|
}
|
27
51
|
get jestConfig() {
|
28
52
|
return this._jestConfig;
|
@@ -31,39 +55,36 @@ class TestConfigOperator {
|
|
31
55
|
return this._testConfig;
|
32
56
|
}
|
33
57
|
mergeJestConfig(sourceConfig) {
|
34
|
-
this._jestConfig = (0,
|
58
|
+
this._jestConfig = (0, import_lodash.merge)({}, this._jestConfig, sourceConfig);
|
35
59
|
}
|
36
60
|
setJestUserConfig() {
|
37
|
-
const {
|
38
|
-
|
39
|
-
} = this;
|
40
|
-
if (typeof userJestConfig === 'object') {
|
61
|
+
const { userJestConfig } = this;
|
62
|
+
if (typeof userJestConfig === "object") {
|
41
63
|
this.setJestConfig(userJestConfig);
|
42
64
|
}
|
43
65
|
}
|
44
66
|
setJestConfig(sourceConfig, options) {
|
45
67
|
if (options) {
|
46
|
-
const {
|
47
|
-
force
|
48
|
-
} = options;
|
68
|
+
const { force } = options;
|
49
69
|
if (force) {
|
50
70
|
this._jestConfig = sourceConfig;
|
51
71
|
return;
|
52
72
|
}
|
53
73
|
}
|
54
|
-
this._jestConfig =
|
74
|
+
this._jestConfig = __spreadValues(__spreadValues({}, this._jestConfig), sourceConfig);
|
55
75
|
}
|
56
76
|
getFinalConfig() {
|
57
|
-
const {
|
58
|
-
userJestConfig
|
59
|
-
} = this;
|
77
|
+
const { userJestConfig } = this;
|
60
78
|
if (!userJestConfig) {
|
61
79
|
return this._jestConfig;
|
62
80
|
}
|
63
|
-
if (typeof userJestConfig ===
|
81
|
+
if (typeof userJestConfig === "function") {
|
64
82
|
return userJestConfig(this._jestConfig);
|
65
83
|
}
|
66
84
|
return this.jestConfig;
|
67
85
|
}
|
68
86
|
}
|
69
|
-
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
88
|
+
0 && (module.exports = {
|
89
|
+
TestConfigOperator
|
90
|
+
});
|
@@ -1,19 +1,46 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var babelTransformer_exports = {};
|
25
|
+
__export(babelTransformer_exports, {
|
26
|
+
default: () => babelTransformer_default
|
5
27
|
});
|
6
|
-
exports
|
7
|
-
var
|
8
|
-
var
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
28
|
+
module.exports = __toCommonJS(babelTransformer_exports);
|
29
|
+
var import_babel_jest = __toESM(require("babel-jest"));
|
30
|
+
var _a, _b;
|
31
|
+
const babelTransformer = (_b = (_a = import_babel_jest.default).createTransformer) == null ? void 0 : _b.call(_a, {
|
32
|
+
presets: [
|
33
|
+
[
|
34
|
+
require.resolve("@modern-js/babel-preset-app"),
|
35
|
+
{
|
36
|
+
appDirectory: process.cwd(),
|
37
|
+
modules: "cjs"
|
38
|
+
}
|
39
|
+
]
|
40
|
+
],
|
15
41
|
configFile: false,
|
16
42
|
babelrc: false
|
17
43
|
});
|
18
|
-
var
|
19
|
-
|
44
|
+
var babelTransformer_default = babelTransformer;
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
46
|
+
0 && (module.exports = {});
|
@@ -1,16 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var hook_exports = {};
|
19
|
+
__export(hook_exports, {
|
20
|
+
afterTestHook: () => afterTestHook,
|
21
|
+
jestConfigHook: () => jestConfigHook,
|
22
|
+
testingHooks: () => testingHooks
|
5
23
|
});
|
6
|
-
|
7
|
-
var
|
8
|
-
const jestConfigHook = (0,
|
9
|
-
|
10
|
-
const afterTestHook = (0, _plugin.createParallelWorkflow)();
|
11
|
-
exports.afterTestHook = afterTestHook;
|
24
|
+
module.exports = __toCommonJS(hook_exports);
|
25
|
+
var import_plugin = require("@modern-js/plugin");
|
26
|
+
const jestConfigHook = (0, import_plugin.createAsyncPipeline)();
|
27
|
+
const afterTestHook = (0, import_plugin.createParallelWorkflow)();
|
12
28
|
const testingHooks = {
|
13
|
-
jestConfig: (0,
|
14
|
-
afterTest: (0,
|
29
|
+
jestConfig: (0, import_plugin.createAsyncPipeline)(),
|
30
|
+
afterTest: (0, import_plugin.createParallelWorkflow)()
|
15
31
|
};
|
16
|
-
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
33
|
+
0 && (module.exports = {
|
34
|
+
afterTestHook,
|
35
|
+
jestConfigHook,
|
36
|
+
testingHooks
|
37
|
+
});
|
@@ -1,66 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
5
|
-
|
6
|
-
var
|
7
|
-
|
8
|
-
runJest: true,
|
9
|
-
getModuleNameMapper: true,
|
10
|
-
DEFAULT_RESOLVER_PATH: true,
|
11
|
-
TestConfigOperator: true,
|
12
|
-
testingHooks: true
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
13
8
|
};
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
});
|
20
|
-
Object.defineProperty(exports, "TestConfigOperator", {
|
21
|
-
enumerable: true,
|
22
|
-
get: function () {
|
23
|
-
return _testConfigOperator.TestConfigOperator;
|
24
|
-
}
|
25
|
-
});
|
26
|
-
Object.defineProperty(exports, "getModuleNameMapper", {
|
27
|
-
enumerable: true,
|
28
|
-
get: function () {
|
29
|
-
return _utils.getModuleNameMapper;
|
30
|
-
}
|
31
|
-
});
|
32
|
-
Object.defineProperty(exports, "runJest", {
|
33
|
-
enumerable: true,
|
34
|
-
get: function () {
|
35
|
-
return _runJest.runJest;
|
36
|
-
}
|
37
|
-
});
|
38
|
-
Object.defineProperty(exports, "runTest", {
|
39
|
-
enumerable: true,
|
40
|
-
get: function () {
|
41
|
-
return _runJest.runTest;
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
42
14
|
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var base_exports = {};
|
20
|
+
__export(base_exports, {
|
21
|
+
DEFAULT_RESOLVER_PATH: () => import_config.DEFAULT_RESOLVER_PATH,
|
22
|
+
TestConfigOperator: () => import_testConfigOperator.TestConfigOperator,
|
23
|
+
getModuleNameMapper: () => import_utils.getModuleNameMapper,
|
24
|
+
runJest: () => import_runJest.runJest,
|
25
|
+
runTest: () => import_runJest.runTest,
|
26
|
+
testingHooks: () => import_hook.testingHooks
|
43
27
|
});
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
28
|
+
module.exports = __toCommonJS(base_exports);
|
29
|
+
var import_runJest = require("./runJest");
|
30
|
+
var import_utils = require("./utils");
|
31
|
+
var import_config = require("./config");
|
32
|
+
var import_testConfigOperator = require("./config/testConfigOperator");
|
33
|
+
var import_hook = require("./hook");
|
34
|
+
__reExport(base_exports, require("./types"), module.exports);
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
36
|
+
0 && (module.exports = {
|
37
|
+
DEFAULT_RESOLVER_PATH,
|
38
|
+
TestConfigOperator,
|
39
|
+
getModuleNameMapper,
|
40
|
+
runJest,
|
41
|
+
runTest,
|
42
|
+
testingHooks
|
49
43
|
});
|
50
|
-
var _runJest = require("./runJest");
|
51
|
-
var _utils = require("./utils");
|
52
|
-
var _config = require("./config");
|
53
|
-
var _testConfigOperator = require("./config/testConfigOperator");
|
54
|
-
var _hook = require("./hook");
|
55
|
-
var _types = require("./types");
|
56
|
-
Object.keys(_types).forEach(function (key) {
|
57
|
-
if (key === "default" || key === "__esModule") return;
|
58
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
59
|
-
if (key in exports && exports[key] === _types[key]) return;
|
60
|
-
Object.defineProperty(exports, key, {
|
61
|
-
enumerable: true,
|
62
|
-
get: function () {
|
63
|
-
return _types[key];
|
64
|
-
}
|
65
|
-
});
|
66
|
-
});
|
@@ -1,32 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __export = (target, all) => {
|
8
|
+
for (var name in all)
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10
|
+
};
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
13
|
+
for (let key of __getOwnPropNames(from))
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16
|
+
}
|
17
|
+
return to;
|
18
|
+
};
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
21
|
+
mod
|
22
|
+
));
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
25
|
+
return new Promise((resolve, reject) => {
|
26
|
+
var fulfilled = (value) => {
|
27
|
+
try {
|
28
|
+
step(generator.next(value));
|
29
|
+
} catch (e) {
|
30
|
+
reject(e);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
var rejected = (value) => {
|
34
|
+
try {
|
35
|
+
step(generator.throw(value));
|
36
|
+
} catch (e) {
|
37
|
+
reject(e);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
42
|
+
});
|
43
|
+
};
|
44
|
+
var runJest_exports = {};
|
45
|
+
__export(runJest_exports, {
|
46
|
+
runJest: () => runJest,
|
47
|
+
runTest: () => runTest
|
5
48
|
});
|
6
|
-
exports
|
7
|
-
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var
|
11
|
-
var
|
12
|
-
|
13
|
-
|
14
|
-
/**
|
15
|
-
* @file run jest by nodejs API
|
16
|
-
* @description
|
17
|
-
* Jest does not provide node API to run jest.
|
18
|
-
* The followed code is inspired by
|
19
|
-
* https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21
|
20
|
-
*/
|
21
|
-
|
22
|
-
const buildArgv = async (rawArgv, config) => {
|
23
|
-
const argv = await (0, _yargs.default)(rawArgv).argv;
|
49
|
+
module.exports = __toCommonJS(runJest_exports);
|
50
|
+
var import_yargs = __toESM(require("yargs/yargs"));
|
51
|
+
var import_jest = require("jest");
|
52
|
+
var import_utils = require("@modern-js/utils");
|
53
|
+
var import_config = require("./config");
|
54
|
+
var import_utils2 = require("./utils");
|
55
|
+
const buildArgv = (rawArgv, config) => __async(void 0, null, function* () {
|
56
|
+
const argv = yield (0, import_yargs.default)(rawArgv).argv;
|
24
57
|
const result = {
|
25
58
|
$0: argv.$0,
|
26
59
|
_: argv._.slice(1)
|
27
60
|
};
|
28
|
-
Object.keys(argv).forEach(key => {
|
29
|
-
if (key.includes(
|
61
|
+
Object.keys(argv).forEach((key) => {
|
62
|
+
if (key.includes("-") || key === "_") {
|
30
63
|
return;
|
31
64
|
}
|
32
65
|
result[key] = argv[key];
|
@@ -35,65 +68,65 @@ const buildArgv = async (rawArgv, config) => {
|
|
35
68
|
result.config = JSON.stringify(config);
|
36
69
|
}
|
37
70
|
return result;
|
38
|
-
};
|
71
|
+
});
|
39
72
|
const readResultsAndExit = (result, globalConfig) => {
|
40
73
|
const code = !result || result.success ? 0 : globalConfig.testFailureExitCode;
|
41
|
-
|
42
|
-
|
43
|
-
process.on('exit', () => {
|
44
|
-
if (typeof code === 'number' && code !== 0) {
|
74
|
+
process.on("exit", () => {
|
75
|
+
if (typeof code === "number" && code !== 0) {
|
45
76
|
process.exitCode = code;
|
46
77
|
}
|
47
78
|
});
|
48
79
|
if (globalConfig.forceExit) {
|
49
80
|
if (!globalConfig.detectOpenHandles) {
|
50
|
-
console.warn(
|
81
|
+
console.warn(
|
82
|
+
`${import_utils.chalk.bold(
|
83
|
+
"Force exiting Jest: "
|
84
|
+
)}Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?`
|
85
|
+
);
|
51
86
|
}
|
52
|
-
|
53
|
-
// eslint-disable-next-line no-process-exit
|
54
87
|
process.exit(code);
|
55
88
|
} else if (!globalConfig.detectOpenHandles) {
|
56
89
|
setTimeout(() => {
|
57
|
-
console.warn(
|
58
|
-
|
90
|
+
console.warn(
|
91
|
+
import_utils.chalk.yellow.bold(
|
92
|
+
"Jest did not exit one second after the test run has completed.\n\n"
|
93
|
+
) + import_utils.chalk.yellow(
|
94
|
+
"This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue."
|
95
|
+
)
|
96
|
+
);
|
97
|
+
}, 1e3).unref();
|
59
98
|
}
|
60
99
|
};
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
readResultsAndExit(results, globalConfig);
|
73
|
-
} catch (e) {
|
74
|
-
console.error(_utils.chalk.red((e === null || e === void 0 ? void 0 : e.stack) || e));
|
75
|
-
|
76
|
-
// eslint-disable-next-line no-process-exit
|
77
|
-
process.exit(1);
|
78
|
-
}
|
100
|
+
function runJest(_0) {
|
101
|
+
return __async(this, arguments, function* (config, pwd = process.cwd()) {
|
102
|
+
try {
|
103
|
+
const argvConfig = yield buildArgv(process.argv.slice(2), config);
|
104
|
+
const { results, globalConfig } = yield (0, import_jest.runCLI)(argvConfig, [pwd]);
|
105
|
+
readResultsAndExit(results, globalConfig);
|
106
|
+
} catch (e) {
|
107
|
+
console.error(import_utils.chalk.red((e == null ? void 0 : e.stack) || e));
|
108
|
+
process.exit(1);
|
109
|
+
}
|
110
|
+
});
|
79
111
|
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
112
|
+
function runTest(_0, _1) {
|
113
|
+
return __async(this, arguments, function* (api, config, pwd = process.cwd()) {
|
114
|
+
process.env.NODE_ENV = "test";
|
115
|
+
const jestUtils = (0, import_config.getJestUtils)(config);
|
116
|
+
yield (0, import_config.patchConfig)(jestUtils);
|
117
|
+
jestUtils.setJestUserConfig();
|
118
|
+
const hookRunners = api.useHookRunners();
|
119
|
+
const testConfigOperator = yield hookRunners.jestConfig(jestUtils, {
|
120
|
+
onLast: (input) => input
|
121
|
+
});
|
122
|
+
const finalConfig = testConfigOperator.getFinalConfig();
|
123
|
+
(0, import_utils2.debug)("Jest config:", finalConfig);
|
124
|
+
yield runJest(finalConfig, pwd);
|
125
|
+
yield hookRunners.afterTest();
|
94
126
|
});
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
127
|
+
}
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
129
|
+
0 && (module.exports = {
|
130
|
+
runJest,
|
131
|
+
runTest
|
132
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
+
var types_exports = {};
|
15
|
+
module.exports = __toCommonJS(types_exports);
|