@rspack-canary/test-tools 1.7.3-canary-1138ed18-20260115124957 → 1.7.3-canary-fe1e14c1-20260116175137

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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.7.3-canary-1138ed18-20260115124957",
3
+ "version": "1.7.3-canary-fe1e14c1-20260116175137",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -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-1138ed18-20260115124957"
68
+ "@rspack/core": "npm:@rspack-canary/core@1.7.3-canary-fe1e14c1-20260116175137"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@rspack/core": ">=1.0.0"