Skip to content

Commit ba3aa4c

Browse files
wraithgarnlf
authored andcommitted
chore(tests): skip coverage for results.sort
We finally know why this is happening, and it's because the array that it is sorting isn't deterministic. Explanation is in the comments above the function, line is ignored, no more random CI test failures. PR-URL: #2523 Credit: @wraithgar Close: #2523 Reviewed-by: @darcyclarke
1 parent d2f8af2 commit ba3aa4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/help-search.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ const searchFiles = async (args, data, files) => {
132132

133133
// sort results by number of results found, then by number of hits
134134
// then by number of matching lines
135+
136+
// coverage is ignored here because the contents of results are
137+
// nondeterministic due to either glob or readFiles or Object.entries
135138
return results.sort((a, b) =>
136139
a.found.length > b.found.length ? -1
137140
: a.found.length < b.found.length ? 1
138141
: a.totalHits > b.totalHits ? -1
139142
: a.totalHits < b.totalHits ? 1
143+
/* istanbul ignore next */
140144
: a.lines.length > b.lines.length ? -1
141145
: a.lines.length < b.lines.length ? 1
142146
: 0).slice(0, 10)

0 commit comments

Comments
 (0)