Skip to content

Commit 3b99272

Browse files
committed
feat: shuffle test suite order in run command
1 parent a130ba3 commit 3b99272

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

bin/codecept.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ program
164164
.option('--tests', 'run only JS test files and skip features')
165165
.option('--no-timeouts', 'disable all timeouts')
166166
.option('-p, --plugins <k=v,k2=v2,...>', 'enable plugins, comma-separated')
167+
.option('--shuffle', 'Shuffle the order in which test files run')
167168

168169
// mocha options
169170
.option('--colors', 'force enabling of colors')

lib/codecept.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { existsSync, readFileSync } = require('fs')
22
const { globSync } = require('glob')
3+
const shuffle = require('lodash.shuffle')
34
const fsPath = require('path')
45
const { resolve } = require('path')
56

@@ -180,6 +181,10 @@ class Codecept {
180181
})
181182
}
182183
}
184+
185+
if (this.opts.shuffle) {
186+
this.testFiles = shuffle(this.testFiles);
187+
}
183188
}
184189

185190
/**

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"joi": "17.13.3",
104104
"js-beautify": "1.15.4",
105105
"lodash.clonedeep": "4.5.0",
106+
"lodash.shuffle": "4.2.0",
106107
"lodash.merge": "4.6.2",
107108
"mkdirp": "3.0.1",
108109
"mocha": "11.6.0",

0 commit comments

Comments
 (0)