@rspack-canary/test-tools 1.6.2-canary-4e6be088-20251110224718 → 1.6.3-canary-74ea720c-20251112173931
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/README.md +1 -1
- package/dist/case/common.js +1 -1
- package/dist/case/defaults.d.ts +1 -1
- package/dist/case/defaults.js +1 -1
- package/dist/helper/directory.d.ts +1 -1
- package/dist/helper/legacy/createLazyTestEnv.d.ts +3 -3
- package/dist/helper/legacy/createLazyTestEnv.js +2 -3
- package/dist/runner/node/index.js +1 -1
- package/dist/test/creator.js +2 -4
- package/dist/type.d.ts +3 -3
- package/dist/type.js +1 -1
- package/package.json +5 -8
- package/rstest.d.ts +24 -0
- package/dist/jest/ignore-snapshot-default-reporter.d.ts +0 -2
- package/dist/jest/ignore-snapshot-default-reporter.js +0 -57
- package/dist/jest/ignore-snapshot-summary-reporter.d.ts +0 -2
- package/dist/jest/ignore-snapshot-summary-reporter.js +0 -24
- package/dist/jest/patch-node-env.d.ts +0 -5
- package/dist/jest/patch-node-env.js +0 -18
- package/dist/jest/slash.d.ts +0 -2
- package/dist/jest/slash.js +0 -16
- package/jest.d.ts +0 -27
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ We expect to reuse the tests for Rspack wasm target as many as possible and we h
|
|
|
16
16
|
2. Set `maxWorkers` to `1`, `maxConcurrency` to `1` and disable concurrent mode to avoid flaky failures.
|
|
17
17
|
3. `forceExit` is needed.
|
|
18
18
|
|
|
19
|
-
Also check all the skipped testcases with `!process.env.WASM` in `test.filter.js`s and the skipped testsuits in `
|
|
19
|
+
Also check all the skipped testcases with `!process.env.WASM` in `test.filter.js`s and the skipped testsuits in `rstest.config.ts`s. They are divided into two categories:
|
|
20
20
|
|
|
21
21
|
1. Skip due to lacks of api support, such as tests related to swc wasm plugins, pnp and profiling. We skip them to avoid obsolete snapshot errors.
|
|
22
22
|
2. Skip temporarily and should be investigate in the future. There could be something wrong with test harness and rspack wasm itself. Since it could be time-consuming to figure out all of them so in this stage we use the wasm test ci to avoid the regression rather than improve its stability.
|
package/dist/case/common.js
CHANGED
|
@@ -132,7 +132,7 @@ async function check(env, context, name) {
|
|
|
132
132
|
}
|
|
133
133
|
async function checkSnapshot(env, context, name, snapshot, filter) {
|
|
134
134
|
if (path_1.default.extname(snapshot) === ".snap") {
|
|
135
|
-
throw new Error("Snapshot with `.snap` will be managed by
|
|
135
|
+
throw new Error("Snapshot with `.snap` will be managed by rstest, please use `.snap.txt` instead");
|
|
136
136
|
}
|
|
137
137
|
const compilerManager = context.getCompiler();
|
|
138
138
|
const stats = compilerManager.getStats();
|
package/dist/case/defaults.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function getRspackDefaultConfig(cwd: string, config: RspackOption
|
|
|
5
5
|
export type TDefaultsCaseConfig = {
|
|
6
6
|
options?: (context: ITestContext) => RspackOptions;
|
|
7
7
|
cwd?: string;
|
|
8
|
-
diff: (diff:
|
|
8
|
+
diff: (diff: Assertion<RspackTestDiff>, defaults: Assertion<RspackOptions>) => Promise<void>;
|
|
9
9
|
description: string;
|
|
10
10
|
};
|
|
11
11
|
declare class RspackTestDiff {
|
package/dist/case/defaults.js
CHANGED
|
@@ -88,7 +88,7 @@ async function run(name, processor) {
|
|
|
88
88
|
context.emitError(e);
|
|
89
89
|
}
|
|
90
90
|
finally {
|
|
91
|
-
await processor.check?.({ expect, it, beforeEach, afterEach,
|
|
91
|
+
await processor.check?.({ expect, it, beforeEach, afterEach, rstest }, context);
|
|
92
92
|
await processor.after?.(context);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -4,8 +4,8 @@ declare function _exports(globalTimeout?: number, nameSuffix?: string): {
|
|
|
4
4
|
it(...args: any[]): void;
|
|
5
5
|
beforeEach(...args: any[]): void;
|
|
6
6
|
afterEach(...args: any[]): void;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
rstest:
|
|
7
|
+
/** @type {import('@rstest/core').Expect} */
|
|
8
|
+
expect: import("@rstest/core").Expect;
|
|
9
|
+
rstest: import("@rstest/core", { with: { "resolution-mode": "import" } }).RstestUtilities;
|
|
10
10
|
};
|
|
11
11
|
export = _exports;
|
|
@@ -109,9 +109,8 @@ module.exports = (globalTimeout = 2000, nameSuffix = "") => {
|
|
|
109
109
|
fixAsyncError(currentDescribeBlock.hooks[currentDescribeBlock.hooks.length - 1]);
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
|
+
/** @type {import('@rstest/core').Expect} */
|
|
112
113
|
expect,
|
|
113
|
-
|
|
114
|
-
// Compatible with rstest
|
|
115
|
-
rstest: global.rstest || global.jest
|
|
114
|
+
rstest,
|
|
116
115
|
};
|
|
117
116
|
};
|
|
@@ -385,7 +385,7 @@ class NodeRunner {
|
|
|
385
385
|
const esmIdentifier = this._options.name;
|
|
386
386
|
return (currentDirectory, modulePath, context = {}) => {
|
|
387
387
|
if (!node_vm_1.SourceTextModule) {
|
|
388
|
-
throw new Error("Running this test requires '--experimental-vm-modules'.\nRun with 'node --experimental-vm-modules node_modules/
|
|
388
|
+
throw new Error("Running this test requires '--experimental-vm-modules'.\nRun with 'node --experimental-vm-modules node_modules/@rstest/core/bin/rstest'.");
|
|
389
389
|
}
|
|
390
390
|
const _require = this.getRequire();
|
|
391
391
|
const file = context.file || this.getFile(modulePath, currentDirectory);
|
package/dist/test/creator.js
CHANGED
|
@@ -242,8 +242,7 @@ class BasicCaseCreator {
|
|
|
242
242
|
expect(typeof fn === "function");
|
|
243
243
|
afterTasks.push(fn);
|
|
244
244
|
},
|
|
245
|
-
|
|
246
|
-
rstest: global.rstest
|
|
245
|
+
rstest
|
|
247
246
|
};
|
|
248
247
|
}
|
|
249
248
|
createEnv(testConfig, options) {
|
|
@@ -255,8 +254,7 @@ class BasicCaseCreator {
|
|
|
255
254
|
it,
|
|
256
255
|
beforeEach,
|
|
257
256
|
afterEach,
|
|
258
|
-
|
|
259
|
-
rstest: global.rstest
|
|
257
|
+
rstest
|
|
260
258
|
};
|
|
261
259
|
}
|
|
262
260
|
clean(folders) {
|
package/dist/type.d.ts
CHANGED
|
@@ -108,10 +108,10 @@ export type TDiffStatsItem = {
|
|
|
108
108
|
};
|
|
109
109
|
export type TDiffStats = {
|
|
110
110
|
root: string;
|
|
111
|
-
data:
|
|
111
|
+
data: TDiffStatsItem[];
|
|
112
112
|
};
|
|
113
113
|
export interface ITestEnv {
|
|
114
|
-
expect:
|
|
114
|
+
expect: Expect;
|
|
115
115
|
it: (...args: any[]) => void;
|
|
116
116
|
beforeEach: (...args: any[]) => void;
|
|
117
117
|
afterEach: (...args: any[]) => void;
|
|
@@ -172,7 +172,7 @@ export declare enum EEsmMode {
|
|
|
172
172
|
}
|
|
173
173
|
export interface IModuleScope extends ITestEnv {
|
|
174
174
|
console: Record<string, (...args: any[]) => void>;
|
|
175
|
-
expect:
|
|
175
|
+
expect: Expect;
|
|
176
176
|
[key: string]: any;
|
|
177
177
|
}
|
|
178
178
|
export interface IGlobalContext {
|
package/dist/type.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspack-canary/test-tools",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3-canary-74ea720c-20251112173931",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Test tools for rspack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
"./helper/*": "./dist/helper/*.js",
|
|
17
17
|
"./helper/legacy/*": "./dist/helper/legacy/*.js",
|
|
18
|
-
"./helper/util/*": "./dist/helper/util/*.js"
|
|
19
|
-
"./jest/*": "./dist/jest/*.js"
|
|
18
|
+
"./helper/util/*": "./dist/helper/util/*.js"
|
|
20
19
|
},
|
|
21
20
|
"files": [
|
|
22
21
|
"client",
|
|
23
22
|
"dist",
|
|
24
23
|
"template",
|
|
25
|
-
"
|
|
24
|
+
"rstest.d.ts"
|
|
26
25
|
],
|
|
27
26
|
"publishConfig": {
|
|
28
27
|
"access": "public",
|
|
@@ -40,15 +39,13 @@
|
|
|
40
39
|
"@babel/parser": "7.28.5",
|
|
41
40
|
"@babel/traverse": "7.28.5",
|
|
42
41
|
"@babel/types": "7.28.5",
|
|
43
|
-
"@jest/reporters": "29.7.0",
|
|
44
42
|
"cross-env": "^10.1.0",
|
|
45
43
|
"filenamify": "4.3.0",
|
|
46
44
|
"fs-extra": "^11.3.2",
|
|
47
|
-
"iconv-lite": "^0.
|
|
45
|
+
"iconv-lite": "^0.7.0",
|
|
48
46
|
"javascript-stringify": "^2.1.0",
|
|
49
47
|
"jest-diff": "^29.7.0",
|
|
50
48
|
"jest-snapshot": "29.7.0",
|
|
51
|
-
"jest-environment-node": "29.7.0",
|
|
52
49
|
"jsdom": "^26.1.0",
|
|
53
50
|
"memfs": "4.48.1",
|
|
54
51
|
"path-serializer": "0.5.1",
|
|
@@ -68,7 +65,7 @@
|
|
|
68
65
|
"@types/jsdom": "^21.1.7",
|
|
69
66
|
"typescript": "^5.9.3",
|
|
70
67
|
"wast-loader": "^1.14.1",
|
|
71
|
-
"@rspack/core": "npm:@rspack-canary/core@1.6.
|
|
68
|
+
"@rspack/core": "npm:@rspack-canary/core@1.6.3-canary-74ea720c-20251112173931"
|
|
72
69
|
},
|
|
73
70
|
"peerDependencies": {
|
|
74
71
|
"@rspack/core": ">=1.0.0"
|
package/rstest.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="@rstest/core/globals" />
|
|
2
|
+
|
|
3
|
+
import type { DiffOptions } from "jest-diff";
|
|
4
|
+
|
|
5
|
+
declare interface FileMatcherOptions {
|
|
6
|
+
diff?: DiffOptions;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module "@rstest/core" {
|
|
10
|
+
interface Assertion {
|
|
11
|
+
toMatchFileSnapshotSync: (
|
|
12
|
+
filename?: string,
|
|
13
|
+
options?: FileMatcherOptions
|
|
14
|
+
) => void;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
type Expect = import("@rstest/core").Expect;
|
|
20
|
+
type Describe = import("@rstest/core").Describe;
|
|
21
|
+
type Assertion<T> = import("@rstest/core").Assertion<T>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
const { DefaultReporter } = require("@jest/reporters");
|
|
4
|
-
const chalk = require.cache[require.resolve("@jest/reporters")].require("chalk");
|
|
5
|
-
const jestUtil = require.cache[require.resolve("@jest/reporters")].require("jest-util");
|
|
6
|
-
const ARROW = " \u203A ";
|
|
7
|
-
const DOT = " \u2022 ";
|
|
8
|
-
const FAIL_COLOR = chalk.bold.red;
|
|
9
|
-
const SNAPSHOT_ADDED = chalk.bold.green;
|
|
10
|
-
const SNAPSHOT_UPDATED = chalk.bold.green;
|
|
11
|
-
const SNAPSHOT_OUTDATED = chalk.bold.yellow;
|
|
12
|
-
function getSnapshotStatus(snapshot, afterUpdate) {
|
|
13
|
-
const statuses = [];
|
|
14
|
-
if (snapshot.added) {
|
|
15
|
-
statuses.push(SNAPSHOT_ADDED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.added)} written.`));
|
|
16
|
-
}
|
|
17
|
-
if (snapshot.updated) {
|
|
18
|
-
statuses.push(SNAPSHOT_UPDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.updated)} updated.`));
|
|
19
|
-
}
|
|
20
|
-
if (snapshot.unmatched) {
|
|
21
|
-
statuses.push(FAIL_COLOR(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unmatched)} failed.`));
|
|
22
|
-
}
|
|
23
|
-
if (snapshot.unchecked) {
|
|
24
|
-
if (afterUpdate) {
|
|
25
|
-
statuses.push(SNAPSHOT_UPDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unchecked)} removed.`));
|
|
26
|
-
for (const key of snapshot.uncheckedKeys) {
|
|
27
|
-
statuses.push(` ${DOT}${key}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
statuses.push(`${SNAPSHOT_OUTDATED(`${ARROW + jestUtil.pluralize("snapshot", snapshot.unchecked)} obsolete`)}.`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (snapshot.fileDeleted) {
|
|
35
|
-
statuses.push(SNAPSHOT_UPDATED(`${ARROW}snapshot file removed.`));
|
|
36
|
-
}
|
|
37
|
-
return statuses;
|
|
38
|
-
}
|
|
39
|
-
const isUpdate = process.argv.includes("-u") || process.argv.includes("--updateSnapshot");
|
|
40
|
-
const isFiltering = process.argv.includes("-t") || process.argv.includes("--testNamePattern");
|
|
41
|
-
const isVerbose = process.argv.includes("--verbose");
|
|
42
|
-
if (!isVerbose && !isUpdate && isFiltering) {
|
|
43
|
-
class IgnoreSnapshotDefaultReporter extends DefaultReporter {
|
|
44
|
-
printTestFileFailureMessage(_testPath, _config, result) {
|
|
45
|
-
if (result.failureMessage) {
|
|
46
|
-
this.log(result.failureMessage);
|
|
47
|
-
}
|
|
48
|
-
const didUpdate = this._globalConfig.updateSnapshot === "all";
|
|
49
|
-
const snapshotStatuses = getSnapshotStatus(result.snapshot, didUpdate);
|
|
50
|
-
snapshotStatuses.forEach(this.log);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
module.exports = IgnoreSnapshotDefaultReporter;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
module.exports = DefaultReporter;
|
|
57
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
const { SummaryReporter } = require("@jest/reporters");
|
|
4
|
-
const chalk = require.cache[require.resolve("@jest/reporters")].require("chalk");
|
|
5
|
-
const isUpdate = process.argv.includes("-u") || process.argv.includes("--updateSnapshot");
|
|
6
|
-
const isFiltering = process.argv.includes("-t") || process.argv.includes("--testNamePattern");
|
|
7
|
-
const isVerbose = process.argv.includes("--verbose");
|
|
8
|
-
if (!isVerbose && !isUpdate && isFiltering) {
|
|
9
|
-
class IgnoreSnapshotSummaryReporter extends SummaryReporter {
|
|
10
|
-
_printSnapshotSummary(snapshots, globalConfig) {
|
|
11
|
-
if (snapshots.added ||
|
|
12
|
-
snapshots.filesRemoved ||
|
|
13
|
-
snapshots.unchecked ||
|
|
14
|
-
snapshots.unmatched ||
|
|
15
|
-
snapshots.updated) {
|
|
16
|
-
this.log(chalk.bold.yellow("Some snapshots are obsoleted, flush with `npm run test -- -u` if necessary.\n"));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
module.exports = IgnoreSnapshotSummaryReporter;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
module.exports = SummaryReporter;
|
|
24
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
// Copied from <https://github.com/webpack/webpack/blob/main/test/patch-node-env.js>
|
|
4
|
-
//
|
|
5
|
-
const NodeEnvironment =
|
|
6
|
-
// For jest@29
|
|
7
|
-
require("jest-environment-node").TestEnvironment ||
|
|
8
|
-
// For jest@27
|
|
9
|
-
require("jest-environment-node");
|
|
10
|
-
class CustomEnvironment extends NodeEnvironment {
|
|
11
|
-
// Workaround for `Symbol('JEST_STATE_SYMBOL')`
|
|
12
|
-
async handleTestEvent(event, state) {
|
|
13
|
-
if (!this.global.JEST_STATE_SYMBOL) {
|
|
14
|
-
this.global.JEST_STATE_SYMBOL = state;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
module.exports = CustomEnvironment;
|
package/dist/jest/slash.d.ts
DELETED
package/dist/jest/slash.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
/**
|
|
4
|
-
* The following code is copied from
|
|
5
|
-
* https://github.com/sindresorhus/slash/blob/98b618f5a3bfcb5dd374b204868818845b87bb2f/index.js
|
|
6
|
-
*
|
|
7
|
-
* MIT Licensed
|
|
8
|
-
* Author Sindre Sorhus @sindresorhus
|
|
9
|
-
*/
|
|
10
|
-
module.exports = function slash(path) {
|
|
11
|
-
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
12
|
-
if (isExtendedLengthPath) {
|
|
13
|
-
return path;
|
|
14
|
-
}
|
|
15
|
-
return path.replace(/\\/g, "/");
|
|
16
|
-
};
|
package/jest.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
|
|
3
|
-
import type { DiffOptions } from "jest-diff";
|
|
4
|
-
|
|
5
|
-
declare interface FileMatcherOptions {
|
|
6
|
-
diff?: DiffOptions;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
namespace jest {
|
|
11
|
-
interface Matchers<R, T> {
|
|
12
|
-
toMatchFileSnapshotSync: (
|
|
13
|
-
filename?: string,
|
|
14
|
-
options?: FileMatcherOptions
|
|
15
|
-
) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Expect {
|
|
19
|
-
toMatchFileSnapshotSync: (
|
|
20
|
-
filename?: string,
|
|
21
|
-
options?: FileMatcherOptions
|
|
22
|
-
) => void;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var rstest = jest;
|
|
27
|
-
}
|