(test, options, state)
| 152 | } |
| 153 | |
| 154 | async function startScreencast(test, options, state) { |
| 155 | const helper = getBrowserHelper() |
| 156 | if (!helper?.page?.screencast) { |
| 157 | if (!state.warnedNoApi) { |
| 158 | output.plugin('screencast', 'page.screencast not available — requires Playwright >= 1.59. Skipping.') |
| 159 | state.warnedNoApi = true |
| 160 | } |
| 161 | return |
| 162 | } |
| 163 | |
| 164 | const baseDir = path.join(store.outputDir || '_output', 'screencast') |
| 165 | mkdirp.sync(baseDir) |
| 166 | const baseName = testToFileName(test, { suffix: '', unique: true }) |
| 167 | state.webmPath = path.join(baseDir, `${baseName}.webm`) |
| 168 | state.srtPath = path.join(baseDir, `${baseName}.srt`) |
| 169 | |
| 170 | const startOpts = { path: state.webmPath } |
| 171 | if (options.size) startOpts.size = options.size |
| 172 | if (options.quality != null) startOpts.quality = options.quality |
| 173 | |
| 174 | try { |
| 175 | await helper.page.screencast.start(startOpts) |
| 176 | state.started = true |
| 177 | } catch (err) { |
| 178 | output.plugin('screencast', `Failed to start: ${err.message}`) |
| 179 | state.webmPath = null |
| 180 | state.srtPath = null |
| 181 | state.started = false |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | if (options.captions && typeof helper.page.screencast.showActions === 'function') { |
| 186 | try { await helper.page.screencast.showActions() } |
| 187 | catch (err) { output.plugin('screencast', `showActions failed: ${err.message}`) } |
| 188 | } |
| 189 | if (typeof helper.page.screencast.showChapter === 'function') { |
| 190 | try { await helper.page.screencast.showChapter(String(test.title || '')) } |
| 191 | catch (err) { output.plugin('screencast', `showChapter failed: ${err.message}`) } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | async function finalizeScreencast(snapshot) { |
| 196 | const { test, options, mode, steps } = snapshot |
no test coverage detected