MCPcopy
hub / github.com/codeceptjs/CodeceptJS / runTests

Method runTests

lib/rerun.js:83–112  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

81 }
82
83 async runTests(test) {
84 const configRerun = this.config.rerun || {}
85 const minSuccess = configRerun.minSuccess || 1
86 const maxReruns = configRerun.maxReruns || 1
87 if (minSuccess > maxReruns) {
88 process.exitCode = 1
89 throw new Error(`run-rerun Configuration Error: minSuccess must be less than maxReruns. Current values: minSuccess=${minSuccess} maxReruns=${maxReruns}`)
90 }
91 if (maxReruns === 1) {
92 await this.runOnce(test)
93 return
94 }
95 let successCounter = 0
96 let rerunsCounter = 0
97 while (rerunsCounter < maxReruns && successCounter < minSuccess) {
98 container.result().reset() // reset result
99 rerunsCounter++
100 try {
101 await this.runOnce(test)
102 successCounter++
103 output.success(`\nProcess run ${rerunsCounter} of max ${maxReruns}, success runs ${successCounter}/${minSuccess}\n`)
104 } catch (e) {
105 output.error(`\nFail run ${rerunsCounter} of max ${maxReruns}, success runs ${successCounter}/${minSuccess} \n`)
106 console.error(e)
107 }
108 }
109 if (successCounter < minSuccess) {
110 throw new Error(`Flaky tests detected! ${successCounter} success runs achieved instead of ${minSuccess} success runs expected`)
111 }
112 }
113
114 async run(test) {
115 event.emit(event.all.before, this)

Callers 1

runMethod · 0.95

Calls 3

runOnceMethod · 0.95
resetMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected