Skip to content

Commit b852648

Browse files
committed
Sort warnings before comparing in tests
1 parent 53cf9fe commit b852648

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

test/utils.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,22 @@ exports.compareError = function compareError(actual, expected) {
4646

4747
exports.compareWarnings = function compareWarnings(actual, expected) {
4848
assert.deepEqual(
49-
actual.map(normaliseError),
50-
expected.map(warning => {
51-
if (warning.frame) {
52-
warning.frame = deindent(warning.frame);
53-
}
54-
return warning;
55-
})
49+
actual.map(normaliseError).sort(sortWarnings),
50+
expected
51+
.map(warning => {
52+
if (warning.frame) {
53+
warning.frame = deindent(warning.frame);
54+
}
55+
return warning;
56+
})
57+
.sort(sortWarnings)
5658
);
5759
};
5860

61+
function sortWarnings(a, b) {
62+
return a === b ? 0 : a < b ? -1 : 1;
63+
}
64+
5965
function deindent(stringValue) {
6066
return stringValue.slice(1).replace(/^\t+/gm, '').replace(/\s+$/gm, '').trim();
6167
}

0 commit comments

Comments
 (0)