Skip to content

Commit 3b1bd86

Browse files
Fixed tests that were failing on Safari
1 parent c5ba66a commit 3b1bd86

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/utils/compare-keys.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,51 @@ function compareKeys (...expected) {
1616
* @returns {boolean}
1717
*/
1818
return function (error) {
19-
let actual = [];
19+
let actual = new Set();
2020

2121
// Make sure all the specified keys exist
2222
for (let key of expected) {
2323
if (key in error) {
24-
actual.push(key);
24+
actual.add(key);
2525
}
2626
}
2727

2828
// Make sure the error doesn't have any extra keys
2929
// eslint-disable-next-line guard-for-in
3030
for (let key in error) {
31-
if (!actual.includes(key)) {
32-
actual.push(key);
33-
}
31+
actual.add(key);
3432
}
3533

3634
if (host.error.hasColumn && "column" in error) {
35+
actual.add("column");
3736
expected.push("column");
3837
}
3938

4039
if (host.error.hasLine && "line" in error) {
40+
actual.add("line");
4141
expected.push("line");
4242
}
4343

4444
if (host.error.hasSourceURL && "sourceURL" in error) {
45+
actual.add("sourceURL");
4546
expected.push("sourceURL");
4647
}
4748

4849
if (host.error.hasEnumerableDescription && "description" in error) {
50+
actual.add("description");
4951
expected.push("description");
5052
}
5153

5254
try {
55+
actual = [...actual];
5356
expect(actual).to.have.same.members(expected);
5457
}
5558
catch (e) {
5659
console.error(`
57-
EXPECTED:
60+
EXPECTED KEYS:
5861
${expected.join("\n ")}
5962
60-
ACTUAL:
63+
ACTUAL KEYS:
6164
${actual.join("\n ")}
6265
`);
6366
throw e;

0 commit comments

Comments
 (0)