Skip to content

Commit 7cb5366

Browse files
fix: guard sort() with shuffle check so --shuffle is not silently ignored (#5639)
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 Co-authored-by: kapilvus <kapilvus@gmail.com>
1 parent eba4a62 commit 7cb5366

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)