Jest-puppeteer: setDefaultTimeout is not respected by .not.toMatchElement()

Created on 25 Feb 2020  路  3Comments  路  Source: smooth-code/jest-puppeteer

馃悰 Bug Report

expect(page).not.toMatchElement() does not respect page.setDefaultTimeout(timeout), and times out after 500ms.

To Reproduce

page.setDefaultTimeout(5 * 1000)
await expect(page).not.toMatchElement('.auth-key.placeholder', { timeout: 5000 })

Expected behavior

I expect it to time out after 5000ms, but it times out after 500ms.


## System:
 - OS: macOS Mojave 10.14.6
 - CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
 - Memory: 76.04 MB / 16.00 GB
 - Shell: 5.3 - /bin/zsh
## Binaries:
 - Node: 11.12.0 - /usr/local/bin/node
 - Yarn: 1.12.3 - /usr/local/bin/yarn
 - npm: 6.11.2 - /usr/local/bin/npm
## npmPackages:
 - jest-dev-server: 4.3.0 => 4.3.0 
 - jest-puppeteer: 4.4.0 => 4.4.0 
bug 馃悰

Most helpful comment

I'm experiencing this with .toMatch(). API documentation says that timeout defaults to 30000 (Jest default timeout), but actually I get tests failing with waiting for function failed: timeout 500ms exceeded 馃槙

All 3 comments

I'm experiencing this with .toMatch(). API documentation says that timeout defaults to 30000 (Jest default timeout), but actually I get tests failing with waiting for function failed: timeout 500ms exceeded 馃槙

await expect(page).toClick('button.js-new-template') also times out after 500ms, despite
page.setDefaultTimeout(7 * 1000).

@lakesare I figured out how to set expect-puppeteer timeout properly: I have a jest.setup.js file, which I add on setupFilesAfterEnv in Jest config. In this file, simply do:

const setDefaultOptions = require('expect-puppeteer').setDefaultOptions

setDefaultOptions({ timeout: 10000 })
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Greg-oliver99 picture Greg-oliver99  路  4Comments

aheissenberger picture aheissenberger  路  5Comments

FezVrasta picture FezVrasta  路  4Comments

testerez picture testerez  路  6Comments

alexander-elgin picture alexander-elgin  路  4Comments