(options, pattern)
| 151 | } |
| 152 | |
| 153 | function 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 | |
| 178 | function suffix(test, options, kind) { |
| 179 | const base = testToFileName(test, { suffix: '', unique: options.uniqueScreenshotNames }) |
no test coverage detected