File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 11const { existsSync, readFileSync } = require ( 'fs' )
22const { globSync } = require ( 'glob' )
3- const shuffle = require ( 'lodash.shuffle' )
43const fsPath = require ( 'path' )
54const { resolve } = require ( 'path' )
65
@@ -186,14 +185,29 @@ class Codecept {
186185 }
187186
188187 if ( this . opts . shuffle ) {
189- this . testFiles = shuffle ( this . testFiles )
188+ this . shuffle ( this . testFiles )
190189 }
191190
192191 if ( this . opts . shard ) {
193192 this . testFiles = this . _applySharding ( this . testFiles , this . opts . shard )
194193 }
195194 }
196195
196+ /**
197+ * Fisher-Yates algorithm for shuffle
198+ */
199+ shuffle ( arrayToShuffle ) {
200+ var i = arrayToShuffle . length ,
201+ j ,
202+ temp
203+ while ( -- i > 0 ) {
204+ j = Math . floor ( Math . random ( ) * ( i + 1 ) )
205+ temp = arrayToShuffle [ j ]
206+ arrayToShuffle [ j ] = arrayToShuffle [ i ]
207+ arrayToShuffle [ i ] = temp
208+ }
209+ }
210+
197211 /**
198212 * Apply sharding to test files based on shard configuration
199213 *
Original file line number Diff line number Diff line change 113113 "js-beautify" : " 1.15.4" ,
114114 "lodash.clonedeep" : " 4.5.0" ,
115115 "lodash.merge" : " 4.6.2" ,
116- "lodash.shuffle" : " 4.2.0" ,
117116 "mkdirp" : " 3.0.1" ,
118117 "mocha" : " 11.7.2" ,
119118 "monocart-coverage-reports" : " 2.12.9" ,
You can’t perform that action at this time.
0 commit comments