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

Function wireOnUrl

lib/plugin/screenshot.js:153–176  ·  view source on GitHub ↗
(options, pattern)

Source from the content-addressed store, hash-verified

151}
152
153function wireOnUrl(options, pattern) {
154 let currentTest = null
155 let stepCount = 0
156 event.dispatcher.on(event.test.before, test => {
157 currentTest = test
158 stepCount = 0
159 })
160 event.dispatcher.on(event.step.after, () => {
161 if (!currentTest) return
162 const helper = getBrowserHelper()
163 if (!helper) return
164 recorder.add('screenshot:url check', async () => {
165 try {
166 const url = await helper.grabCurrentUrl()
167 if (!matchUrl(url, pattern)) return
168 stepCount++
169 const name = `${testToFileName(currentTest, { suffix: '', unique: options.uniqueScreenshotNames })}.url_${stepCount}.png`
170 await takeScreenshot(currentTest, name, options)
171 } catch (err) {
172 // page may not be ready
173 }
174 })
175 })
176}
177
178function suffix(test, options, kind) {
179 const base = testToFileName(test, { suffix: '', unique: options.uniqueScreenshotNames })

Callers 1

screenshot.jsFile · 0.85

Calls 6

getBrowserHelperFunction · 0.90
matchUrlFunction · 0.90
testToFileNameFunction · 0.90
takeScreenshotFunction · 0.85
addMethod · 0.45
grabCurrentUrlMethod · 0.45

Tested by

no test coverage detected