MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / Section

Class Section

lib/step/section.js:6–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4let currentSection
5
6class Section {
7 constructor(name = '') {
8 this.name = name
9
10 this.metaStep = new MetaStep(null, name)
11
12 this.attachMetaStep = step => {
13 if (currentSection !== this) return
14 if (!step) return
15 const metaStep = getRootMetaStep(step)
16
17 if (metaStep !== this.metaStep) {
18 metaStep.metaStep = this.metaStep
19 }
20 }
21 }
22
23 hidden() {
24 this.metaStep.collapsed = true
25 return this
26 }
27
28 start() {
29 if (currentSection) currentSection.end()
30 currentSection = this
31 event.dispatcher.prependListener(event.step.before, this.attachMetaStep)
32 event.dispatcher.once(event.test.finished, () => this.end())
33 return this
34 }
35
36 end() {
37 currentSection = null
38 event.dispatcher.off(event.step.started, this.attachMetaStep)
39 return this
40 }
41
42 /**
43 * @returns {Section}
44 */
45 static current() {
46 return currentSection
47 }
48}
49
50function getRootMetaStep(step) {
51 if (step.metaStep) return getRootMetaStep(step.metaStep)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected