diff --git a/lib/codecept.js b/lib/codecept.js index 3efbab82d..4c28afc6d 100644 --- a/lib/codecept.js +++ b/lib/codecept.js @@ -289,8 +289,11 @@ class Codecept { // Ignore if gherkin module not available } - // Sort test files alphabetically for consistent execution order - this.testFiles.sort() + // Sort test files alphabetically for consistent execution order, + // but skip sorting when --shuffle is active so the randomised order is preserved. + if (!this.opts.shuffle) { + this.testFiles.sort() + } return new Promise((resolve, reject) => { const mocha = container.mocha()