Skip to content

Commit 6af67eb

Browse files
feat(puppeteer): disable screenshot in Node 16
1 parent 7aa20fa commit 6af67eb

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

docs/puppeteer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| `--browser` | `$/puppeteer.js` |
66
|---|---|
77
| Module | [puppeteer](https://www.npmjs.com/package/puppeteer) |
8-
| Screenshots | ✔️ `.png` |
8+
| Screenshots 1️⃣ | ✔️ `.png` |
99
| Scripts | ✔️ |
1010
| Traces | `console`, `network` |
1111

@@ -20,4 +20,4 @@
2020

2121
## Implementation notes
2222

23-
N/A
23+
* 1️⃣ Screenshot feature is **failing** because of missing [`structuredClone` API](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility) on Node.js 16. Since the problem is **inside** `puppeteer` ([issue](https://github.com/puppeteer/puppeteer/issues/11004)), the feature is turned off for this version.

src/defaults/puppeteer.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,26 @@ require('./browser')({
1212
['-h, --viewport-height <height>', 'Viewport height', 1080],
1313
['-l, --language <lang...>', 'Language(s)', ['en-US']],
1414
['-u, --unsecure', 'Disable security features', false]
15-
],
16-
capabilities: {
15+
] // ,
16+
// TODO restore when Node16 is no more supported
17+
// capabilities: {
18+
// modules: ['puppeteer'],
19+
// screenshot: '.png',
20+
// scripts: true,
21+
// traces: ['console', 'network']
22+
// }
23+
},
24+
25+
// TODO remove when Node16 is no more supported
26+
async capabilities () {
27+
const version = process.version.match(/^v(\d+\.\d+)/)[1]
28+
let screenshot
29+
if (!version.startsWith('16')) {
30+
screenshot = '.png'
31+
}
32+
return {
1733
modules: ['puppeteer'],
18-
screenshot: '.png',
34+
screenshot,
1935
scripts: true,
2036
traces: ['console', 'network']
2137
}

0 commit comments

Comments
 (0)