Skip to content

Commit 3417a39

Browse files
committed
migrate rspack wasm test to rstest
1 parent 0e9ec16 commit 3417a39

File tree

4 files changed

+44
-47
lines changed

4 files changed

+44
-47
lines changed

packages/rspack-test-tools/src/helper/setup-env.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ if (process.env.RSTEST) {
1919
global.__ROOT_PATH__ ??= process.env.__ROOT_PATH__;
2020
global.__RSPACK_PATH__ ??= process.env.__RSPACK_PATH__;
2121
global.__RSPACK_TEST_TOOLS_PATH__ ??= process.env.__RSPACK_TEST_TOOLS_PATH__;
22-
} else {
23-
// Compatible with wasm tests (lazyTestEnv)
24-
global.rstest = jest;
2522
}
2623

2724
if (process.env.ALTERNATIVE_SORT) {

packages/rspack-test-tools/src/test/creator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export class BasicCaseCreator {
8787
testConfig,
8888
options
8989
);
90-
const concurrent = process.env.WASM
91-
? false
92-
: testConfig.concurrent || options.concurrent;
90+
const concurrent = testConfig.concurrent || options.concurrent;
9391
if (options.describe) {
9492
if (run) {
9593
if (concurrent) {

tests/rspack-test/jest.config.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,6 @@ const setupFilesAfterEnv = [
66
"@rspack/test-tools/setup-env"
77
];
88

9-
/** @type {import('jest').Config} */
10-
const wasmConfig = process.env.WASM && {
11-
setupFilesAfterEnv: [...setupFilesAfterEnv, "@rspack/test-tools/setup-wasm"],
12-
testPathIgnorePatterns: [
13-
// Skip because they reply on snapshots
14-
"Diagnostics.test.js",
15-
"Error.test.js",
16-
"StatsAPI.test.js",
17-
"StatsOutput.test.js",
18-
// Skip because the loader can not be loaded in CI
19-
"HotWeb.test.js",
20-
"HotWorker.test.js",
21-
"HotNode.test.js",
22-
23-
// Skip temporarily and should investigate in the future
24-
"HotSnapshot.hottest.js",
25-
"Defaults.test.js",
26-
"Cache.test.js",
27-
"Compiler.test.js",
28-
"Serial.test.js",
29-
"Example.test.js",
30-
"Incremental-async-node.test.js",
31-
"Incremental-node.test.js",
32-
"Incremental-watch-webpack.test.js",
33-
"Incremental-watch.test.js",
34-
"Incremental-web.test.js",
35-
"Incremental-webworker.test.js",
36-
"NativeWatcher.test.js",
37-
"NativeWatcher-webpack.test.js"
38-
],
39-
maxWorkers: 1,
40-
maxConcurrency: 1,
41-
forceExit: true
42-
};
43-
449
/** @type {import('jest').Config} */
4510
const config = {
4611
testEnvironment: "@rspack/test-tools/jest/patch-node-env",
@@ -51,10 +16,7 @@ const config = {
5116
],
5217
testTimeout: process.env.CI ? 60000 : 30000,
5318
prettierPath: require.resolve("prettier-2"),
54-
testMatch: process.env.WASM ? [
55-
"<rootDir>/*.test.js",
56-
"<rootDir>/legacy-test/*.test.js"
57-
] : [
19+
testMatch: [
5820
"<rootDir>/legacy-test/*.test.js",
5921
"<rootDir>/Cache.test.js",
6022
"<rootDir>/Incremental-async-node.test.js",
@@ -104,7 +66,6 @@ const config = {
10466
__RSPACK_PATH__: path.resolve(root, "packages/rspack"),
10567
__RSPACK_TEST_TOOLS_PATH__: path.resolve(root, "packages/rspack-test-tools"),
10668
},
107-
...(wasmConfig || {}),
10869
verbose: true,
10970
};
11071

tests/rspack-test/rstest.config.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,50 @@ const setupFilesAfterEnv = [
77
"@rspack/test-tools/setup-expect",
88
];
99

10+
const wasmConfig = process.env.WASM && defineConfig({
11+
setupFiles: [...setupFilesAfterEnv, "@rspack/test-tools/setup-wasm"],
12+
exclude: [
13+
// Skip because they reply on snapshots
14+
"Diagnostics.test.js",
15+
"Error.test.js",
16+
"StatsAPI.test.js",
17+
"StatsOutput.test.js",
18+
// Skip because the loader can not be loaded in CI
19+
"HotWeb.test.js",
20+
"HotWorker.test.js",
21+
"HotNode.test.js",
22+
23+
// Skip temporarily and should investigate in the future
24+
"HotSnapshot.hottest.js",
25+
"Defaults.test.js",
26+
"Cache.test.js",
27+
"Compiler.test.js",
28+
"Serial.test.js",
29+
"Example.test.js",
30+
"Incremental-async-node.test.js",
31+
"Incremental-node.test.js",
32+
"Incremental-watch-webpack.test.js",
33+
"Incremental-watch.test.js",
34+
"Incremental-web.test.js",
35+
"Incremental-webworker.test.js",
36+
"NativeWatcher.test.js",
37+
"NativeWatcher-webpack.test.js",
38+
39+
// Rstest ignored
40+
"EsmOutput.test.js",
41+
],
42+
maxConcurrency: 1,
43+
pool: {
44+
maxWorkers: 1,
45+
execArgv: ['--no-warnings', '--expose-gc', '--max-old-space-size=8192', '--experimental-vm-modules'],
46+
}
47+
});
48+
49+
1050
export default defineConfig({
1151
setupFiles: setupFilesAfterEnv,
1252
testTimeout: process.env.CI ? 60000 : 30000,
13-
include: process.env.WASM ? [] : [
53+
include: [
1454
"<rootDir>/*.test.js",
1555
],
1656
exclude: ["Cache.test.js", "Incremental-*.test.js", "Hot*.test.js", "Serial.test.js", "NativeWatcher*.test.js", "Diagnostics.test.js", "EsmOutput.test.js"],
@@ -63,5 +103,6 @@ export default defineConfig({
63103
},
64104
reporters: process.env.CI ? undefined : ["verbose"],
65105
hideSkippedTests: true,
106+
...(wasmConfig || {}),
66107
});
67108

0 commit comments

Comments
 (0)