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

Function wireScreencast

lib/plugin/screencast.js:85–152  ·  view source on GitHub ↗
(mode, options)

Source from the content-addressed store, hash-verified

83}
84
85function wireScreencast(mode, options) {
86 const state = {
87 test: null,
88 webmPath: null,
89 srtPath: null,
90 steps: null,
91 startedAt: null,
92 failed: false,
93 startQueued: false,
94 started: false,
95 warnedNoApi: false,
96 }
97
98 event.dispatcher.on(event.test.before, test => {
99 state.test = test
100 state.failed = false
101 state.webmPath = null
102 state.srtPath = null
103 state.startQueued = false
104 state.started = false
105 state.steps = options.subtitles ? {} : null
106 state.startedAt = options.subtitles ? Date.now() : null
107 })
108
109 event.dispatcher.on(event.test.started, test => {
110 if (!options.video || state.startQueued) return
111 state.startQueued = true
112 recorder.add('screencast:start', async () => startScreencast(state.test, options, state), true)
113 })
114
115 event.dispatcher.on(event.step.started, step => {
116 if (state.steps) {
117 const at = Date.now()
118 step.id = step.id || uuidv4()
119 state.steps[step.id] = {
120 start: formatTimestamp(at - state.startedAt),
121 startedAt: at,
122 title: stepTitle(step),
123 }
124 }
125 })
126
127 if (options.subtitles) {
128 event.dispatcher.on(event.step.finished, step => {
129 if (!state.steps || !step?.id || !state.steps[step.id]) return
130 state.steps[step.id].end = formatTimestamp(Date.now() - state.startedAt)
131 })
132 }
133
134 event.dispatcher.on(event.test.failed, (test, _err, hookName) => {
135 if (hookName === 'BeforeSuite' || hookName === 'AfterSuite') return
136 state.failed = true
137 })
138
139 event.dispatcher.on(event.test.after, () => {
140 if (!state.test) return
141 recorder.add('screencast:stop', async () => finalizeScreencast({
142 test: state.test,

Callers 1

screencast.jsFile · 0.85

Calls 5

startScreencastFunction · 0.85
formatTimestampFunction · 0.85
stepTitleFunction · 0.85
finalizeScreencastFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected