Repository navigation
Playwright: I.waitForText() causes unexpected delay equal to waitForTimeout value at the end of test suite #4999
Copy link
Copy link
Closed
Description
It's a regression in 3.7.0 (also 3.7.3 is affected). It works well in 3.6.10.
Steps:
Run this test using npx codeceptjs run --verbose --colors|ts; date (it logs a current time during the test and after it)
Feature('My');
Scenario('test something', ({ I }) => {
I.amOnPage('https://example.com');
I.waitForText('Example Domain');
});Expected result:
- No delay when the test finishes, you get a shell immediately
Actual result:
- It waits for
waitForTimeoutwhen the test finishes, in my case 30 secs.
mirao@jobr-ubuntu:~/tmp$ npx codeceptjs run --verbose --colors|ts; date
May 26 11:43:52 Deprecation Warning: 'tryTo' has been moved to the 'codeceptjs/effects' module. Disable tryTo plugin to remove this warning.
May 26 11:43:52 Deprecation Warning: 'retryTo' has been moved to the 'codeceptjs/effects' module. Disable retryTo plugin to remove this warning.
May 26 11:43:52 ***************************************
May 26 11:43:52 nodeInfo: 20.19.0
May 26 11:43:52 osInfo: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
May 26 11:43:52 cpuInfo: (16) x64 AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
May 26 11:43:52 chromeInfo: 136.0.7103.113
May 26 11:43:52 edgeInfo: "N/A"
May 26 11:43:52 firefoxInfo: undefined
May 26 11:43:52 safariInfo: N/A
May 26 11:43:52 playwrightBrowsers: "chromium: 136.0.7103.25, firefox: 137.0, webkit: 18.4"
May 26 11:43:52 If you need more detailed info, just run this: npx codeceptjs info
May 26 11:43:52 ***************************************
May 26 11:43:52 CodeceptJS v3.7.3 #StandWithUkraine
May 26 11:43:52 Using test root "/home/mirao/tmp"
May 26 11:43:52 Helpers: Playwright
May 26 11:43:52 Plugins: screenshotOnFail, tryTo, retryFailedStep, retryTo, eachElement
May 26 11:43:52
May 26 11:43:52 My --
May 26 11:43:52 /home/mirao/tmp/My_test.js
May 26 11:43:52 [1] Starting recording promises
May 26 11:43:52 Timeouts:
May 26 11:43:52 › [Session] Starting singleton browser session
May 26 11:43:52 test something
May 26 11:43:52 › [New Session] {"ignoreHTTPSErrors":false,"acceptDownloads":true}
May 26 11:43:52 Scenario()
May 26 11:43:52 I am on page "https://example.com"
May 26 11:43:53 I wait for text "Example Domain"
May 26 11:43:53 ✔ OK in 671ms
May 26 11:43:53
May 26 11:43:53
May 26 11:43:53 OK | 1 passed // 1s
Mon 26 May 11:44:23 CEST 2025
mirao@jobr-ubuntu:~/tmp$
config
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();
/** @type {CodeceptJS.MainConfig} */
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost',
show: true,
waitForTimeout: 30000
}
},
include: {
I: './steps_file.js'
},
name: 'tmp'
}Used SW:
- CodeceptJS 3.7.3
- Playwright 1.52, Chromium
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
incoming-th commentedon Jul 10, 2025
@mirao Not sure if that could help, I remember having this issue when switching from Puppeteer to Playwright, but checking my code I have something similar to what you have.
Difference if I have:
waitForNavigation: 'networkidle',Maybe try with that?
mirao commentedon Aug 2, 2025
@incoming-th
Possible values are only these
CodeceptJS/lib/helper/Playwright.js
Line 78 in 2aef872
I tested all of them and the issue occurs always, it doesn't depend on that option..
incoming-th commentedon Aug 20, 2025
@mirao I see @kobenguyent asked co-pilot to fix this. I am not sure this is the solution of a race condition, but you could confirm with your test?
kobenguyent commentedon Aug 21, 2025
just had a chance to verify that it worked like a charm.
Did a bit dirty job to add timestamp, so please ignore the timezone here. Just focus on the seconds.
incoming-th commentedon Aug 21, 2025
@kobenguyent Excellent, thank you for your hard work and for taking time to double check solution from AI!
mirao commentedon Aug 21, 2025
@kobenguyent
I patched my
Playwright.jsby the fix and it works well, no delay occurs when the test finishes.But there is a regression 🐛 -
I.waitForText()doesn't wait forwaitForTimeoutif the string can't be found. It waits for a short time only.Could you reopen it?
test:
Before the fix - the method waits for 30 secs ✔️
After the fix - the method waits for 4 secs only 🐛
kobenguyent commentedon Aug 22, 2025
@mirao thanks for reporting the issue, I'd say let's check and improve all wait* methods of Playwright helper -> #5092
mirao commentedon Aug 22, 2025
@kobenguyent Thank you very much