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

Function enhanceMochaSuite

lib/mocha/suite.js:9–42  ·  view source on GitHub ↗

* Enhances MochaSuite with CodeceptJS specific functionality using composition

(suite)

Source from the content-addressed store, hash-verified

7 * Enhances MochaSuite with CodeceptJS specific functionality using composition
8 */
9function enhanceMochaSuite(suite) {
10 if (!suite) suite = new MochaSuite('Suite', null, false)
11 // already enhanced
12 if (suite.codeceptjs) return suite
13
14 suite.codeceptjs = true
15 // Add properties
16 suite.tags = suite.title.match(/(\@[a-zA-Z0-9-_]+)/g) || []
17 suite.opts = {}
18 // suite.totalTimeout = undefined
19
20 // Override fullTitle method
21 suite.fullTitle = () => `${suite.title}:`
22
23 // Add new methods
24 suite.applyOptions = function (opts) {
25 if (!opts) opts = {}
26 suite.opts = opts
27
28 if (opts.retries) suite.retries(opts.retries)
29 if (opts.timeout) suite.totalTimeout = opts.timeout
30
31 if (opts.skipInfo && opts.skipInfo.skipped) {
32 suite.pending = true
33 suite.opts = { ...this.opts, skipInfo: opts.skipInfo }
34 }
35 }
36
37 suite.simplify = function () {
38 return serializeSuite(this)
39 }
40
41 return suite
42}
43
44/**
45 * Factory function to create enhanced suites

Callers 7

gherkinParserFunction · 0.90
enhanceMochaTestFunction · 0.90
deserializeTestFunction · 0.90
suiteSetupFunction · 0.85
suiteTeardownFunction · 0.85
createSuiteFunction · 0.85
deserializeSuiteFunction · 0.85

Calls 1

serializeSuiteFunction · 0.85

Tested by

no test coverage detected