← Back to Discord Forum

toHaveScreenshot does not use the default timeout

rosica.popkostovaposted in #help-playwright
Open in Discord

Hello everyone, hope that this is the right channel from my question 🙂 I have a test that does visual testing and I am using .toHaveScreenshot as an expect (await expect(pickPage.page).toHaveScreenshot('hue-filter-expected.png')). My test is failing because the expect does not wait for the default timeout but instead is taking the consecutive screenshots immidately. Does anyone of you have an idea how to fix this ? I don't want to use .waitForTimeout since there is already the default one which should enough

This thread is trying to answer question "How can I make .toHaveScreenshot wait for the default timeout instead of taking consecutive screenshots immediately?"

1 reply

Do you know what your expect timeout is set to in your playwright config? If you specify a timeout in toHaveScreenshot() does it wait? e.g. await expect(pickPage.page).toHaveScreenshot('hue-filter-expected.png', { timeout: 5000 });

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.