Skip to content

Commit

Permalink
fix(goto): pass waitUntil (#420)
Browse files Browse the repository at this point in the history
* fix(goto): pass waitUntil

* perf(screenshot): cache height & width values
  • Loading branch information
Kikobeats committed Oct 5, 2022
1 parent f0ddebc commit 7b0d2c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/goto/src/index.js
Expand Up @@ -364,9 +364,11 @@ module.exports = ({
await Promise.all(prePromises.concat(applyEvasions))

const { value: response, reason: error } = await run({
fn: html ? page.setContent(html, args) : page.goto(url, args),
fn: html
? page.setContent(html, { waitUntil, ...args })
: page.goto(url, { waitUntil, ...args }),
timeout: gotoTimeout,
debug: html ? 'html' : 'url'
debug: { fn: html ? 'html' : 'url', waitUntil }
})

for (const [key, value] of Object.entries({
Expand Down
2 changes: 1 addition & 1 deletion packages/screenshot/src/index.js
Expand Up @@ -98,7 +98,7 @@ module.exports = ({ goto, ...gotoOpts }) => {
screenshot = await page.screenshot({ ...opts, ...screenshotOpts })
debug('screenshot', { waitUntil, duration: prettyMs(timeScreenshot()) })
} else {
;({ response } = await goto(page, { ...opts, url, waitUntilAuto }))
;({ response } = await goto(page, { ...opts, url, waitUntil, waitUntilAuto }))
async function waitUntilAuto (page, { response }) {
const [screenshotOpts] = await Promise.all([
waitForElement(page, element),
Expand Down
6 changes: 4 additions & 2 deletions packages/screenshot/src/is-white-screenshot.js
Expand Up @@ -5,9 +5,11 @@ const jimp = require('jimp')
module.exports = async buffer => {
const image = await jimp.read(buffer)
const firstPixel = image.getPixelColor(0, 0)
const height = image.getHeight()
const width = image.getWidth()

for (let i = 0; i < image.getHeight(); i++) {
for (let j = 0; j < image.getWidth(); j++) {
for (let i = 0; i < height; i++) {
for (let j = 0; j < width; j++) {
if (firstPixel !== image.getPixelColor(j, i)) return false
}
}
Expand Down

0 comments on commit 7b0d2c8

Please sign in to comment.