Skip to content

Commit 1741e46

Browse files
committed
fix: guard sort() with shuffle check so --shuffle is not silently ignored
sort() added in #5438 was unconditional — it ran after loadTests() applied shuffle(), overwriting the randomised order every time. Guard the sort with !this.opts.shuffle so alphabetical order is used for normal runs and the shuffled order is preserved when --shuffle is requested. Fixes #5605
1 parent eba4a62 commit 1741e46

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/codecept.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,11 @@ class Codecept {
289289
// Ignore if gherkin module not available
290290
}
291291

292-
// Sort test files alphabetically for consistent execution order
293-
this.testFiles.sort()
292+
// Sort test files alphabetically for consistent execution order,
293+
// but skip sorting when --shuffle is active so the randomised order is preserved.
294+
if (!this.opts.shuffle) {
295+
this.testFiles.sort()
296+
}
294297

295298
return new Promise((resolve, reject) => {
296299
const mocha = container.mocha()

0 commit comments

Comments
 (0)