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

Method constructor

lib/mocha/cli.js:35–186  ·  view source on GitHub ↗
(runner, opts)

Source from the content-addressed store, hash-verified

33
34class Cli extends Base {
35 constructor(runner, opts) {
36 super(runner)
37 let level = 0
38 this.loadedTests = []
39 opts = opts.reporterOptions || opts
40 if (opts.steps) level = 1
41 if (opts.debug) level = 2
42 if (opts.verbose) level = 3
43 output.level(level)
44 output.print(`CodeceptJS v${codeceptVersion} ${output.standWithUkraine()}`)
45 output.print(`Using test root "${store.codeceptDir}"`)
46
47 const showSteps = level >= 1
48
49 if (level >= 2) {
50 // Load container asynchronously to avoid circular dependency
51 getContainer().then(Container => {
52 output.print(output.styles.debug(`Helpers: ${Object.keys(Container.helpers()).join(', ')}`))
53 output.print(output.styles.debug(`Plugins: ${Object.keys(Container.plugins()).join(', ')}`))
54 }).catch(() => {
55 // Silently fail if container can't be loaded
56 output.print(output.styles.debug('Helpers: [loading...]'))
57 output.print(output.styles.debug('Plugins: [loading...]'))
58 })
59 }
60
61 if (level >= 3) {
62 process.on('warning', warning => {
63 console.log('\nWarning Details:')
64 console.log('Name:', warning.name)
65 console.log('Message:', warning.message)
66 console.log('Stack:', warning.stack)
67 console.log('-------------------')
68 })
69 }
70
71 runner.on('start', () => {
72 console.log()
73 })
74
75 runner.on('suite', suite => {
76 output.suite.started(suite)
77 })
78
79 runner.on('fail', test => {
80 if (test.ctx.currentTest) {
81 this.loadedTests.push(test.ctx.currentTest.uid)
82 }
83 if (showSteps && test.steps) {
84 return output.scenario.failed(test)
85 }
86 cursor.CR()
87 output.test.failed(test)
88 })
89
90 runner.on('pending', test => {
91 if (test.parent && test.parent.pending) {
92 const suite = test.parent

Callers

nothing calls this directly

Calls 13

getContainerFunction · 0.85
skipTestConfigFunction · 0.85
matchTestFunction · 0.85
debugMethod · 0.80
helpersMethod · 0.80
pluginsMethod · 0.80
logMethod · 0.80
startedMethod · 0.80
pushMethod · 0.80
isBDDMethod · 0.80
includesMethod · 0.80
addStatsMethod · 0.80

Tested by

no test coverage detected