@modern-js/plugin-testing 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +145 -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 +11 -6
- 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 +64 -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 +56 -18
- package/dist/js/node/base/config/patches/assetsModule.js +30 -12
- package/dist/js/node/base/config/patches/filemock.js +22 -7
- package/dist/js/node/base/config/patches/index.js +50 -15
- package/dist/js/node/base/config/patches/transformer.js +38 -25
- package/dist/js/node/base/config/resolver.js +37 -10
- package/dist/js/node/base/config/testConfigOperator.js +49 -30
- package/dist/js/node/base/config/transformer/babelTransformer.js +40 -15
- package/dist/js/node/base/hook.js +28 -13
- package/dist/js/node/base/index.js +31 -63
- package/dist/js/node/base/runJest.js +99 -71
- package/dist/js/node/base/utils.js +66 -34
- package/dist/js/node/cli/bff/app.js +57 -22
- package/dist/js/node/cli/bff/constant.js +22 -7
- package/dist/js/node/cli/bff/index.js +121 -65
- package/dist/js/node/cli/bff/mockAPI.js +103 -71
- package/dist/js/node/cli/bff/setup.js +100 -38
- package/dist/js/node/cli/bff/utils/index.js +55 -22
- package/dist/js/node/cli/index.js +87 -46
- package/dist/js/node/cli/test.js +79 -27
- package/dist/js/node/constant.js +22 -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 +30 -33
- 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 +67 -31
- package/dist/js/node/runtime-testing/request.js +32 -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 +24 -11
- 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 +248 -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/resolver.d.ts +2 -1
- 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 +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,150 @@
|
|
|
1
1
|
# @modern-js/plugin-testing
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
|
|
12
|
+
refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
|
|
13
|
+
- 14b712da84: fix: use consistent alias type and default value across packages
|
|
14
|
+
|
|
15
|
+
fix: 在各个包中使用一致的 alias 类型定义和默认值
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [2344eb26ed]
|
|
18
|
+
- Updated dependencies [a11fcf8b50]
|
|
19
|
+
- Updated dependencies [a931594]
|
|
20
|
+
- Updated dependencies [e7ce063]
|
|
21
|
+
- Updated dependencies [b18fa8f3ed]
|
|
22
|
+
- Updated dependencies [7879e8f]
|
|
23
|
+
- Updated dependencies [50d4675]
|
|
24
|
+
- Updated dependencies [c9e800d39a]
|
|
25
|
+
- Updated dependencies [6604f1b]
|
|
26
|
+
- Updated dependencies [d032d49e09]
|
|
27
|
+
- Updated dependencies [6aca875]
|
|
28
|
+
- Updated dependencies [fda836f]
|
|
29
|
+
- Updated dependencies [15bf09d9c8]
|
|
30
|
+
- Updated dependencies [d6bc321]
|
|
31
|
+
- Updated dependencies [3e57f2bd58]
|
|
32
|
+
- Updated dependencies [2e6031955e]
|
|
33
|
+
- Updated dependencies [c5798d2]
|
|
34
|
+
- Updated dependencies [fbf5eed5aa]
|
|
35
|
+
- Updated dependencies [a2509bfbdb]
|
|
36
|
+
- Updated dependencies [a7c6883]
|
|
37
|
+
- Updated dependencies [425e57092d]
|
|
38
|
+
- Updated dependencies [decfcd989d]
|
|
39
|
+
- Updated dependencies [e4357f1856]
|
|
40
|
+
- Updated dependencies [7b7d12c]
|
|
41
|
+
- Updated dependencies [4369648ae2]
|
|
42
|
+
- Updated dependencies [92f0eade39]
|
|
43
|
+
- Updated dependencies [92c0994468]
|
|
44
|
+
- Updated dependencies [2cc2eb3]
|
|
45
|
+
- Updated dependencies [edd1cfb1af]
|
|
46
|
+
- Updated dependencies [cc971eabfc]
|
|
47
|
+
- Updated dependencies [5b9049f2e9]
|
|
48
|
+
- Updated dependencies [6bda14ed71]
|
|
49
|
+
- Updated dependencies [92004d1906]
|
|
50
|
+
- Updated dependencies [b8bbe036c7]
|
|
51
|
+
- Updated dependencies [40ed5874c6]
|
|
52
|
+
- Updated dependencies [60d5378632]
|
|
53
|
+
- Updated dependencies [d5a31df781]
|
|
54
|
+
- Updated dependencies [dda38c9c3e]
|
|
55
|
+
- Updated dependencies [102d32e4ba]
|
|
56
|
+
- Updated dependencies [8b8e1bb571]
|
|
57
|
+
- Updated dependencies [3bbea92b2a]
|
|
58
|
+
- Updated dependencies [73cd29dd9f]
|
|
59
|
+
- Updated dependencies [9144c21]
|
|
60
|
+
- Updated dependencies [b710adb843]
|
|
61
|
+
- Updated dependencies [cce8ecee2d]
|
|
62
|
+
- Updated dependencies [18aaf42249]
|
|
63
|
+
- Updated dependencies [34702d5]
|
|
64
|
+
- Updated dependencies [f179749375]
|
|
65
|
+
- Updated dependencies [fcace5b5b9]
|
|
66
|
+
- Updated dependencies [ea7cf06]
|
|
67
|
+
- Updated dependencies [bbe4c4a]
|
|
68
|
+
- Updated dependencies [e4558a0]
|
|
69
|
+
- Updated dependencies [abf3421a75]
|
|
70
|
+
- Updated dependencies [543be9558e]
|
|
71
|
+
- Updated dependencies [fd1d9fd]
|
|
72
|
+
- Updated dependencies [14b712da84]
|
|
73
|
+
- @modern-js/runtime@2.0.0-beta.4
|
|
74
|
+
- @modern-js/prod-server@2.0.0-beta.4
|
|
75
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
76
|
+
- @modern-js/babel-preset-app@2.0.0-beta.4
|
|
77
|
+
- @modern-js/plugin@2.0.0-beta.4
|
|
78
|
+
- @modern-js/babel-compiler@2.0.0-beta.4
|
|
79
|
+
|
|
80
|
+
## 2.0.0-beta.3
|
|
81
|
+
|
|
82
|
+
### Major Changes
|
|
83
|
+
|
|
84
|
+
- dda38c9c3e: chore: v2
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
|
|
89
|
+
refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
|
|
90
|
+
- 14b712da84: fix: use consistent alias type and default value across packages
|
|
91
|
+
|
|
92
|
+
fix: 在各个包中使用一致的 alias 类型定义和默认值
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [2344eb26ed]
|
|
95
|
+
- Updated dependencies [a11fcf8b50]
|
|
96
|
+
- Updated dependencies [e7ce063]
|
|
97
|
+
- Updated dependencies [b18fa8f3ed]
|
|
98
|
+
- Updated dependencies [c9e800d39a]
|
|
99
|
+
- Updated dependencies [6604f1b]
|
|
100
|
+
- Updated dependencies [d032d49e09]
|
|
101
|
+
- Updated dependencies [6aca875]
|
|
102
|
+
- Updated dependencies [fda836f]
|
|
103
|
+
- Updated dependencies [15bf09d9c8]
|
|
104
|
+
- Updated dependencies [3e57f2bd58]
|
|
105
|
+
- Updated dependencies [2e60319]
|
|
106
|
+
- Updated dependencies [fbf5eed5aa]
|
|
107
|
+
- Updated dependencies [a2509bfbdb]
|
|
108
|
+
- Updated dependencies [425e570]
|
|
109
|
+
- Updated dependencies [decfcd989d]
|
|
110
|
+
- Updated dependencies [e4357f1]
|
|
111
|
+
- Updated dependencies [4369648ae2]
|
|
112
|
+
- Updated dependencies [92f0eade39]
|
|
113
|
+
- Updated dependencies [92c0994468]
|
|
114
|
+
- Updated dependencies [edd1cfb1af]
|
|
115
|
+
- Updated dependencies [cc971eabfc]
|
|
116
|
+
- Updated dependencies [5b9049f2e9]
|
|
117
|
+
- Updated dependencies [6bda14ed71]
|
|
118
|
+
- Updated dependencies [92004d1906]
|
|
119
|
+
- Updated dependencies [b8bbe036c7]
|
|
120
|
+
- Updated dependencies [40ed5874c6]
|
|
121
|
+
- Updated dependencies [60d5378632]
|
|
122
|
+
- Updated dependencies [d5a31df781]
|
|
123
|
+
- Updated dependencies [dda38c9c3e]
|
|
124
|
+
- Updated dependencies [102d32e4ba]
|
|
125
|
+
- Updated dependencies [8b8e1bb571]
|
|
126
|
+
- Updated dependencies [3bbea92b2a]
|
|
127
|
+
- Updated dependencies [73cd29dd9f]
|
|
128
|
+
- Updated dependencies [b710adb]
|
|
129
|
+
- Updated dependencies [cce8ece]
|
|
130
|
+
- Updated dependencies [18aaf42249]
|
|
131
|
+
- Updated dependencies [34702d5]
|
|
132
|
+
- Updated dependencies [f179749375]
|
|
133
|
+
- Updated dependencies [fcace5b5b9]
|
|
134
|
+
- Updated dependencies [ea7cf06]
|
|
135
|
+
- Updated dependencies [bbe4c4a]
|
|
136
|
+
- Updated dependencies [e4558a0]
|
|
137
|
+
- Updated dependencies [abf3421a75]
|
|
138
|
+
- Updated dependencies [543be9558e]
|
|
139
|
+
- Updated dependencies [fd1d9fd]
|
|
140
|
+
- Updated dependencies [14b712da84]
|
|
141
|
+
- @modern-js/runtime@2.0.0-beta.3
|
|
142
|
+
- @modern-js/prod-server@2.0.0-beta.3
|
|
143
|
+
- @modern-js/utils@2.0.0-beta.3
|
|
144
|
+
- @modern-js/babel-preset-app@2.0.0-beta.3
|
|
145
|
+
- @modern-js/plugin@2.0.0-beta.3
|
|
146
|
+
- @modern-js/babel-compiler@2.0.0-beta.3
|
|
147
|
+
|
|
3
148
|
## 2.0.0-beta.2
|
|
4
149
|
|
|
5
150
|
### Major Changes
|
|
@@ -1,16 +1,36 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
1
21
|
import { applyPatches } from "./patches";
|
|
2
22
|
import { TestConfigOperator } from "./testConfigOperator";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Parse jest config
|
|
6
|
-
*/
|
|
7
|
-
const getJestUtils = testConfig => {
|
|
23
|
+
const getJestUtils = (testConfig) => {
|
|
8
24
|
const testOperator = new TestConfigOperator(testConfig);
|
|
9
25
|
return testOperator;
|
|
10
26
|
};
|
|
11
|
-
const patchConfig =
|
|
12
|
-
|
|
27
|
+
const patchConfig = (testOperator) => __async(void 0, null, function* () {
|
|
28
|
+
yield applyPatches(testOperator);
|
|
13
29
|
return testOperator.jestConfig;
|
|
30
|
+
});
|
|
31
|
+
const DEFAULT_RESOLVER_PATH = require.resolve("./resolver");
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_RESOLVER_PATH,
|
|
34
|
+
getJestUtils,
|
|
35
|
+
patchConfig
|
|
14
36
|
};
|
|
15
|
-
export const DEFAULT_RESOLVER_PATH = require.resolve("./resolver");
|
|
16
|
-
export { getJestUtils, patchConfig };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
* Merge config from testConfig.jest
|
|
3
|
-
*/
|
|
4
|
-
export const patchAssetsModule = testOperator => {
|
|
1
|
+
const patchAssetsModule = (testOperator) => {
|
|
5
2
|
testOperator.mergeJestConfig({
|
|
6
3
|
moduleNameMapper: {
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
"\\.(css|less|scss|sass)$": require.resolve("identity-obj-proxy"),
|
|
5
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": require.resolve("./filemock.js")
|
|
9
6
|
}
|
|
10
7
|
});
|
|
11
|
-
};
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
patchAssetsModule
|
|
11
|
+
};
|
|
@@ -1,11 +1,34 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
1
21
|
import { patchTransformer } from "./transformer";
|
|
2
22
|
import { patchAssetsModule } from "./assetsModule";
|
|
3
|
-
const _applyPatches =
|
|
4
|
-
for (const patch of
|
|
5
|
-
|
|
23
|
+
const _applyPatches = (patches2, testOperator) => __async(void 0, null, function* () {
|
|
24
|
+
for (const patch of patches2) {
|
|
25
|
+
yield patch(testOperator);
|
|
6
26
|
}
|
|
7
|
-
};
|
|
27
|
+
});
|
|
8
28
|
const patches = [patchTransformer, patchAssetsModule];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
29
|
+
const applyPatches = (testConfig) => __async(void 0, null, function* () {
|
|
30
|
+
yield _applyPatches(patches, testConfig);
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
applyPatches
|
|
34
|
+
};
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
import { readCompilerOptions } from "../../utils";
|
|
2
2
|
const resolveTsCompilerOptions = () => {
|
|
3
3
|
const tsCompilerOptions = readCompilerOptions() || {};
|
|
4
|
-
const {
|
|
5
|
-
jsx
|
|
6
|
-
} = tsCompilerOptions;
|
|
4
|
+
const { jsx } = tsCompilerOptions;
|
|
7
5
|
if (!jsx) {
|
|
8
6
|
return null;
|
|
9
7
|
}
|
|
10
|
-
tsCompilerOptions.jsx =
|
|
8
|
+
tsCompilerOptions.jsx = "react-jsx";
|
|
11
9
|
return tsCompilerOptions;
|
|
12
10
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
export const patchTransformer = testOperator => {
|
|
18
|
-
const {
|
|
19
|
-
transformer
|
|
20
|
-
} = testOperator.testConfig;
|
|
21
|
-
if (transformer === 'babel-jest') {
|
|
11
|
+
const patchTransformer = (testOperator) => {
|
|
12
|
+
const { transformer } = testOperator.testConfig;
|
|
13
|
+
if (transformer === "babel-jest") {
|
|
22
14
|
testOperator.mergeJestConfig({
|
|
23
15
|
transform: {
|
|
24
|
-
|
|
16
|
+
"\\.[jt]sx?$": require.resolve("../transformer/babelTransformer")
|
|
25
17
|
}
|
|
26
18
|
});
|
|
27
19
|
}
|
|
28
|
-
if (transformer ===
|
|
20
|
+
if (transformer === "ts-jest") {
|
|
29
21
|
testOperator.mergeJestConfig({
|
|
30
22
|
transform: {
|
|
31
|
-
|
|
23
|
+
"\\.[jt]sx?$": require.resolve("ts-jest")
|
|
32
24
|
}
|
|
33
25
|
});
|
|
34
26
|
const compilerOptions = resolveTsCompilerOptions();
|
|
35
27
|
compilerOptions && testOperator.mergeJestConfig({
|
|
36
28
|
globals: {
|
|
37
|
-
|
|
29
|
+
"ts-jest": {
|
|
38
30
|
tsconfig: compilerOptions
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
33
|
});
|
|
42
34
|
}
|
|
43
|
-
};
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
patchTransformer
|
|
38
|
+
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import enhanceResolve from
|
|
1
|
+
import enhanceResolve from "enhanced-resolve";
|
|
2
2
|
const resolver = enhanceResolve.create.sync({
|
|
3
|
-
conditionNames: [
|
|
4
|
-
extensions: [
|
|
3
|
+
conditionNames: ["require", "node", "default"],
|
|
4
|
+
extensions: [".js", ".json", ".node", ".ts", ".tsx"]
|
|
5
5
|
});
|
|
6
|
-
const shouldResolveByEnhance = url => /^@[^/]+\/[^/]+\/.*/.test(url);
|
|
7
|
-
|
|
6
|
+
const shouldResolveByEnhance = (url) => /^@[^/]+\/[^/]+\/.*/.test(url);
|
|
7
|
+
const internalResolve = function(request, options) {
|
|
8
8
|
if (shouldResolveByEnhance(request)) {
|
|
9
9
|
return resolver(options.basedir, request);
|
|
10
10
|
}
|
|
11
11
|
return options.defaultResolver(request, options);
|
|
12
|
-
};
|
|
12
|
+
};
|
|
13
|
+
module.exports = internalResolve;
|
|
14
|
+
var resolver_default = internalResolve;
|
|
15
|
+
export {
|
|
16
|
+
resolver_default as default
|
|
17
|
+
};
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { merge } from "@modern-js/utils/lodash";
|
|
5
18
|
class TestConfigOperator {
|
|
6
19
|
constructor(testConfig) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
_defineProperty(this, "defaultTestConfig", {
|
|
11
|
-
transformer: 'babel-jest'
|
|
12
|
-
});
|
|
20
|
+
this.defaultTestConfig = {
|
|
21
|
+
transformer: "babel-jest"
|
|
22
|
+
};
|
|
13
23
|
this._testConfig = testConfig;
|
|
14
24
|
this._jestConfig = {};
|
|
15
25
|
this.userJestConfig = testConfig.jest;
|
|
@@ -28,36 +38,32 @@ class TestConfigOperator {
|
|
|
28
38
|
this._jestConfig = merge({}, this._jestConfig, sourceConfig);
|
|
29
39
|
}
|
|
30
40
|
setJestUserConfig() {
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
} = this;
|
|
34
|
-
if (typeof userJestConfig === 'object') {
|
|
41
|
+
const { userJestConfig } = this;
|
|
42
|
+
if (typeof userJestConfig === "object") {
|
|
35
43
|
this.setJestConfig(userJestConfig);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
setJestConfig(sourceConfig, options) {
|
|
39
47
|
if (options) {
|
|
40
|
-
const {
|
|
41
|
-
force
|
|
42
|
-
} = options;
|
|
48
|
+
const { force } = options;
|
|
43
49
|
if (force) {
|
|
44
50
|
this._jestConfig = sourceConfig;
|
|
45
51
|
return;
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
|
-
this._jestConfig =
|
|
54
|
+
this._jestConfig = __spreadValues(__spreadValues({}, this._jestConfig), sourceConfig);
|
|
49
55
|
}
|
|
50
56
|
getFinalConfig() {
|
|
51
|
-
const {
|
|
52
|
-
userJestConfig
|
|
53
|
-
} = this;
|
|
57
|
+
const { userJestConfig } = this;
|
|
54
58
|
if (!userJestConfig) {
|
|
55
59
|
return this._jestConfig;
|
|
56
60
|
}
|
|
57
|
-
if (typeof userJestConfig ===
|
|
61
|
+
if (typeof userJestConfig === "function") {
|
|
58
62
|
return userJestConfig(this._jestConfig);
|
|
59
63
|
}
|
|
60
64
|
return this.jestConfig;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
export {
|
|
67
|
+
export {
|
|
68
|
+
TestConfigOperator
|
|
69
|
+
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
import babelJest from
|
|
3
|
-
const babelTransformer = (
|
|
4
|
-
presets: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import babelJest from "babel-jest";
|
|
3
|
+
const babelTransformer = (_b = (_a = babelJest).createTransformer) == null ? void 0 : _b.call(_a, {
|
|
4
|
+
presets: [
|
|
5
|
+
[
|
|
6
|
+
require.resolve("@modern-js/babel-preset-app"),
|
|
7
|
+
{
|
|
8
|
+
appDirectory: process.cwd(),
|
|
9
|
+
modules: "cjs"
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
],
|
|
8
13
|
configFile: false,
|
|
9
14
|
babelrc: false
|
|
10
15
|
});
|
|
11
|
-
|
|
16
|
+
var babelTransformer_default = babelTransformer;
|
|
17
|
+
export {
|
|
18
|
+
babelTransformer_default as default
|
|
19
|
+
};
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { createAsyncPipeline, createParallelWorkflow } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createAsyncPipeline, createParallelWorkflow } from "@modern-js/plugin";
|
|
2
|
+
const jestConfigHook = createAsyncPipeline();
|
|
3
|
+
const afterTestHook = createParallelWorkflow();
|
|
4
|
+
const testingHooks = {
|
|
5
5
|
jestConfig: createAsyncPipeline(),
|
|
6
6
|
afterTest: createParallelWorkflow()
|
|
7
|
-
};
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
afterTestHook,
|
|
10
|
+
jestConfigHook,
|
|
11
|
+
testingHooks
|
|
12
|
+
};
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export * from "./types";
|
|
1
|
+
import { runTest, runJest } from "./runJest";
|
|
2
|
+
import { getModuleNameMapper } from "./utils";
|
|
3
|
+
import { DEFAULT_RESOLVER_PATH } from "./config";
|
|
4
|
+
import { TestConfigOperator } from "./config/testConfigOperator";
|
|
5
|
+
import { testingHooks } from "./hook";
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export {
|
|
8
|
+
DEFAULT_RESOLVER_PATH,
|
|
9
|
+
TestConfigOperator,
|
|
10
|
+
getModuleNameMapper,
|
|
11
|
+
runJest,
|
|
12
|
+
runTest,
|
|
13
|
+
testingHooks
|
|
14
|
+
};
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import yargs from "yargs/yargs";
|
|
22
|
+
import { runCLI } from "jest";
|
|
23
|
+
import { chalk } from "@modern-js/utils";
|
|
12
24
|
import { getJestUtils, patchConfig } from "./config";
|
|
13
25
|
import { debug } from "./utils";
|
|
14
|
-
const buildArgv =
|
|
15
|
-
const argv =
|
|
26
|
+
const buildArgv = (rawArgv, config) => __async(void 0, null, function* () {
|
|
27
|
+
const argv = yield yargs(rawArgv).argv;
|
|
16
28
|
const result = {
|
|
17
29
|
$0: argv.$0,
|
|
18
30
|
_: argv._.slice(1)
|
|
19
31
|
};
|
|
20
|
-
Object.keys(argv).forEach(key => {
|
|
21
|
-
if (key.includes(
|
|
32
|
+
Object.keys(argv).forEach((key) => {
|
|
33
|
+
if (key.includes("-") || key === "_") {
|
|
22
34
|
return;
|
|
23
35
|
}
|
|
24
36
|
result[key] = argv[key];
|
|
@@ -27,65 +39,64 @@ const buildArgv = async (rawArgv, config) => {
|
|
|
27
39
|
result.config = JSON.stringify(config);
|
|
28
40
|
}
|
|
29
41
|
return result;
|
|
30
|
-
};
|
|
42
|
+
});
|
|
31
43
|
const readResultsAndExit = (result, globalConfig) => {
|
|
32
44
|
const code = !result || result.success ? 0 : globalConfig.testFailureExitCode;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
process.on('exit', () => {
|
|
36
|
-
if (typeof code === 'number' && code !== 0) {
|
|
45
|
+
process.on("exit", () => {
|
|
46
|
+
if (typeof code === "number" && code !== 0) {
|
|
37
47
|
process.exitCode = code;
|
|
38
48
|
}
|
|
39
49
|
});
|
|
40
50
|
if (globalConfig.forceExit) {
|
|
41
51
|
if (!globalConfig.detectOpenHandles) {
|
|
42
|
-
console.warn(
|
|
52
|
+
console.warn(
|
|
53
|
+
`${chalk.bold(
|
|
54
|
+
"Force exiting Jest: "
|
|
55
|
+
)}Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?`
|
|
56
|
+
);
|
|
43
57
|
}
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line no-process-exit
|
|
46
58
|
process.exit(code);
|
|
47
59
|
} else if (!globalConfig.detectOpenHandles) {
|
|
48
60
|
setTimeout(() => {
|
|
49
|
-
console.warn(
|
|
50
|
-
|
|
61
|
+
console.warn(
|
|
62
|
+
chalk.yellow.bold(
|
|
63
|
+
"Jest did not exit one second after the test run has completed.\n\n"
|
|
64
|
+
) + chalk.yellow(
|
|
65
|
+
"This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue."
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
}, 1e3).unref();
|
|
51
69
|
}
|
|
52
70
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
readResultsAndExit(results, globalConfig);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
console.error(chalk.red((e === null || e === void 0 ? void 0 : e.stack) || e));
|
|
67
|
-
|
|
68
|
-
// eslint-disable-next-line no-process-exit
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
+
function runJest(_0) {
|
|
72
|
+
return __async(this, arguments, function* (config, pwd = process.cwd()) {
|
|
73
|
+
try {
|
|
74
|
+
const argvConfig = yield buildArgv(process.argv.slice(2), config);
|
|
75
|
+
const { results, globalConfig } = yield runCLI(argvConfig, [pwd]);
|
|
76
|
+
readResultsAndExit(results, globalConfig);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.error(chalk.red((e == null ? void 0 : e.stack) || e));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
71
82
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
function runTest(_0, _1) {
|
|
84
|
+
return __async(this, arguments, function* (api, config, pwd = process.cwd()) {
|
|
85
|
+
process.env.NODE_ENV = "test";
|
|
86
|
+
const jestUtils = getJestUtils(config);
|
|
87
|
+
yield patchConfig(jestUtils);
|
|
88
|
+
jestUtils.setJestUserConfig();
|
|
89
|
+
const hookRunners = api.useHookRunners();
|
|
90
|
+
const testConfigOperator = yield hookRunners.jestConfig(jestUtils, {
|
|
91
|
+
onLast: (input) => input
|
|
92
|
+
});
|
|
93
|
+
const finalConfig = testConfigOperator.getFinalConfig();
|
|
94
|
+
debug("Jest config:", finalConfig);
|
|
95
|
+
yield runJest(finalConfig, pwd);
|
|
96
|
+
yield hookRunners.afterTest();
|
|
86
97
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
runJest,
|
|
101
|
+
runTest
|
|
102
|
+
};
|