@rspack-canary/test-tools 1.7.3-canary-58d41d16-20260115035302 → 1.7.3-canary-ef467b46-20260115180501

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.
@@ -1,7 +1,11 @@
1
1
  export declare const isDirectory: (p: string) => boolean;
2
2
  export declare const isFile: (p: string) => boolean;
3
3
  export declare const isValidCaseDirectory: (name: string) => boolean;
4
- export declare function describeByWalk(testFile: string, createCase: (name: string, src: string, dist: string) => void, options?: {
4
+ export declare function describeByWalk(
5
+ /**
6
+ * The test file absolute path.
7
+ */
8
+ testFile: string, createCase: (name: string, src: string, dist: string) => void, options?: {
5
9
  type?: 'file' | 'directory';
6
10
  level?: number;
7
11
  source?: string;
@@ -14,7 +14,11 @@ const isFile = (p) => node_fs_1.default.lstatSync(p).isFile();
14
14
  exports.isFile = isFile;
15
15
  const isValidCaseDirectory = (name) => !name.startsWith('_') && !name.startsWith('.') && name !== 'node_modules';
16
16
  exports.isValidCaseDirectory = isValidCaseDirectory;
17
- function describeByWalk(testFile, createCase, options = {}) {
17
+ function describeByWalk(
18
+ /**
19
+ * The test file absolute path.
20
+ */
21
+ testFile, createCase, options = {}) {
18
22
  const describeFn = options.describe || describe;
19
23
  const testBasename = node_path_1.default
20
24
  .basename(testFile)
@@ -22,6 +26,7 @@ function describeByWalk(testFile, createCase, options = {}) {
22
26
  const testId = testBasename.charAt(0).toLowerCase() + testBasename.slice(1);
23
27
  const sourceBase = options.source || node_path_1.default.join(node_path_1.default.dirname(testFile), `${testId}Cases`);
24
28
  const testSourceId = node_path_1.default.basename(sourceBase);
29
+ const absoluteTestDir = node_path_1.default.dirname(testFile);
25
30
  const distBase = options.dist || node_path_1.default.join(node_path_1.default.dirname(testFile), 'js', testId);
26
31
  const level = options.level || 2;
27
32
  const type = options.type || 'directory';
@@ -59,7 +64,15 @@ function describeByWalk(testFile, createCase, options = {}) {
59
64
  .join(`${testId}Cases-${testSourceId}`, caseName)
60
65
  .split('.')
61
66
  .shift());
62
- describeFn(name, () => {
67
+ let suiteName = name;
68
+ // support filter test by absolute path
69
+ if (process.env.testFilter?.includes(absoluteTestDir)) {
70
+ const fullCasePath = node_path_1.default.join(absoluteTestDir, testSourceId, caseName);
71
+ if (fullCasePath.includes(process.env.testFilter)) {
72
+ suiteName = fullCasePath;
73
+ }
74
+ }
75
+ describeFn(suiteName, () => {
63
76
  const source = node_path_1.default.join(sourceBase, caseName);
64
77
  let dist = '';
65
78
  if (absoluteDist) {
@@ -74,7 +87,7 @@ function describeByWalk(testFile, createCase, options = {}) {
74
87
  dist = node_path_1.default.join(sourceBase, caseName, relativeDist);
75
88
  }
76
89
  }
77
- createCase(name, source, dist);
90
+ createCase(suiteName, source, dist);
78
91
  });
79
92
  }
80
93
  });
@@ -33,6 +33,8 @@ class LazyCompilationTestPlugin {
33
33
  resolve(null);
34
34
  });
35
35
  server.on('request', (req, res) => {
36
+ // Set CORS headers for jsdom's XMLHttpRequest
37
+ res.setHeader('Access-Control-Allow-Origin', '*');
36
38
  middleware(req, res, () => { });
37
39
  });
38
40
  server.on('connection', (socket) => {
@@ -152,7 +152,11 @@ class WebRunner extends node_1.NodeRunner {
152
152
  createBaseModuleScope() {
153
153
  const moduleScope = super.createBaseModuleScope();
154
154
  moduleScope.EventSource = EventSourceForNode_1.default;
155
- moduleScope.fetch = async (url) => {
155
+ moduleScope.fetch = async (url, options) => {
156
+ // For Lazy Compilation Proxy the POST request to the real dev server.
157
+ if (options?.method === 'POST') {
158
+ return fetch(url, options);
159
+ }
156
160
  try {
157
161
  const filePath = this.urlToPath(url);
158
162
  this.log(`fetch: ${url} -> ${filePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.7.3-canary-58d41d16-20260115035302",
3
+ "version": "1.7.3-canary-ef467b46-20260115180501",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -35,14 +35,14 @@
35
35
  "directory": "packages/rspack-test-tools"
36
36
  },
37
37
  "dependencies": {
38
- "@babel/generator": "7.28.5",
39
- "@babel/parser": "7.28.5",
40
- "@babel/traverse": "7.28.5",
41
- "@babel/types": "7.28.5",
38
+ "@babel/generator": "7.28.6",
39
+ "@babel/parser": "7.28.6",
40
+ "@babel/traverse": "7.28.6",
41
+ "@babel/types": "7.28.6",
42
42
  "cross-env": "^10.1.0",
43
43
  "filenamify": "4.3.0",
44
44
  "fs-extra": "^11.3.3",
45
- "iconv-lite": "^0.7.1",
45
+ "iconv-lite": "^0.7.2",
46
46
  "javascript-stringify": "^2.1.0",
47
47
  "jest-diff": "^30.2.0",
48
48
  "jest-snapshot": "29.7.0",
@@ -65,7 +65,7 @@
65
65
  "@types/jsdom": "^21.1.7",
66
66
  "typescript": "^5.9.3",
67
67
  "wast-loader": "^1.14.1",
68
- "@rspack/core": "npm:@rspack-canary/core@1.7.3-canary-58d41d16-20260115035302"
68
+ "@rspack/core": "npm:@rspack-canary/core@1.7.3-canary-ef467b46-20260115180501"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@rspack/core": ">=1.0.0"