jest-puppeteer icon indicating copy to clipboard operation
jest-puppeteer copied to clipboard

setDefaultTimeout is not respected by .not.toMatchElement()

Open lakesare opened this issue 4 years ago • 4 comments

🐛 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 

lakesare avatar Feb 25 '20 04:02 lakesare

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 😕

stefanteixeira avatar Mar 10 '20 06:03 stefanteixeira

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

lakesare avatar Jul 10 '20 08:07 lakesare

@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 })

stefanteixeira avatar Jul 11 '20 04:07 stefanteixeira

Using setDefaultOptions() in my setupFilesAfterEnv-equivalent does not help and I still get TimeoutError for waitForFunction: (here used with toClick())

#   TimeoutError: Element button (text: "Search") not found
#
#   waiting for function failed: timeout 500ms exceeded

Setting page.setDefaultTimeout(10000); in explicitly in my tests does not help either.

BangKarlsen avatar Nov 25 '21 08:11 BangKarlsen

Please upgrade to v8 and reopen submit a new issue if you experience this problem.

gregberge avatar Mar 07 '23 08:03 gregberge