@@ -10,6 +10,8 @@ const { devices, getDevice } = require('./devices')
10
10
11
11
const ABORT_TYPES = [ 'image' , 'media' , 'stylesheet' , 'font' , 'xhr' ]
12
12
13
+ const WAIT_UNTIL = [ 'networkidle2' , 'load' , 'domcontentloaded' ]
14
+
13
15
module . exports = launchOpts => {
14
16
let browser = puppeteer . launch ( launchOpts )
15
17
@@ -26,15 +28,8 @@ module.exports = launchOpts => {
26
28
return text
27
29
}
28
30
29
- const html = async (
30
- url ,
31
- opts = {
32
- waitFor : 0 ,
33
- waitUntil : [ 'networkidle2' ] ,
34
- abortTypes : ABORT_TYPES
35
- }
36
- ) => {
37
- const { abortTypes, waitFor } = opts
31
+ const html = async ( url , opts = { } ) => {
32
+ const { abortTypes = ABORT_TYPES , waitFor = 0 , ...gotoOpts } = opts
38
33
39
34
const page = await newPage ( )
40
35
await page . setRequestInterception ( true )
@@ -47,7 +42,7 @@ module.exports = launchOpts => {
47
42
return req [ action ] ( )
48
43
} )
49
44
50
- await page . goto ( url , opts )
45
+ await page . goto ( url , Object . assign ( { waitUntil : WAIT_UNTIL } ) , gotoOpts )
51
46
if ( waitFor ) await page . waitFor ( waitFor )
52
47
const content = await page . content ( )
53
48
0 commit comments