@rspack-canary/test-tools 1.6.8-canary-02b3377e-20251215174244 → 1.6.8-canary-2fd81281-20251216180302

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.
@@ -87,20 +87,50 @@ module.exports = async function checkArrayExpectation(testDirectory, object, kin
87
87
  done(new Error(`Less ${kind}s (${array.length} instead of ${expected.length}) while compiling than expected:\n\n${diff}\n\nCheck expected ${kind}s: ${expectedFilename}`));
88
88
  return true;
89
89
  }
90
+ const usedExpected = new Array(expected.length).fill(false);
90
91
  for (let i = 0; i < array.length; i++) {
91
- if (Array.isArray(expected[i])) {
92
- for (let j = 0; j < expected[i].length; j++) {
93
- if (!check(expected[i][j], array[i])) {
94
- done(new Error(`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[i][j])}`));
95
- return true;
92
+ let found = false;
93
+ for (let j = 0; j < expected.length; j++) {
94
+ if (usedExpected[j])
95
+ continue;
96
+ if (Array.isArray(expected[j])) {
97
+ for (let k = 0; k < expected[j].length; k++) {
98
+ if (check(expected[j][k], array[i])) {
99
+ usedExpected[j] = true;
100
+ found = true;
101
+ break;
102
+ }
96
103
  }
97
104
  }
105
+ else {
106
+ if (check(expected[j], array[i])) {
107
+ usedExpected[j] = true;
108
+ found = true;
109
+ break;
110
+ }
111
+ }
112
+ if (found)
113
+ break;
98
114
  }
99
- else if (!check(expected[i], array[i])) {
100
- done(new Error(`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match ${explain(expected[i])}`));
115
+ if (!found) {
116
+ done(new Error(`${upperCaseKind} ${i}: ${explain(array[i])} doesn't match any expected value`));
101
117
  return true;
102
118
  }
103
119
  }
120
+ const unused = [];
121
+ for (let j = 0; j < expected.length; j++) {
122
+ if (!usedExpected[j]) {
123
+ unused.push(Array.isArray(expected[j])
124
+ ? expected[j].map(explain).join(' | ')
125
+ : explain(expected[j]));
126
+ }
127
+ }
128
+ if (unused.length > 0) {
129
+ done(new Error(`The following expected ${kind}s were not matched:\n${unused
130
+ .map(u => ` ${u}`)
131
+ .join('\n')}`));
132
+ return true;
133
+ }
104
134
  }
105
135
  else if (array.length > 0) {
106
136
  done(new Error(`${upperCaseKind}s while compiling:\n\n${array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.6.8-canary-02b3377e-20251215174244",
3
+ "version": "1.6.8-canary-2fd81281-20251216180302",
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.6.8-canary-02b3377e-20251215174244"
68
+ "@rspack/core": "npm:@rspack-canary/core@1.6.8-canary-2fd81281-20251216180302"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@rspack/core": ">=1.0.0"