To change the default test timeout in the Playwright Test configuration file, you need to modify the timeout
property in the config
object. Here's how you can do it:
Locate or create the playwright.config.ts
file in your project directory.
Inside the playwright.config.ts
file, export a config
object with the timeout
property set to the desired value in milliseconds. For example, to set the default test timeout to 120 seconds (2 minutes), you can use the following code:
export const config = {
// ...
// Set global test time out
"timeout": 120000,
};
This configuration will apply the new default test timeout to all tests in your project.
Remember that changing the global test timeout does not affect the timeouts of individual functions like waitForURL()
. You can still override the timeout for specific functions by passing an options object with a timeout
property. For example:
await page.waitForURL('https://ray.run', { timeout: 60000 });
This will set the timeout for waitForURL()
to 60 seconds, regardless of the global test timeout.
By adjusting the default test timeout in the configuration file and using function-specific timeouts when needed, you can optimize your @playwright/test scripts for better performance and reliability.
If you still have questions, please ask a question and I will try to answer it.
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 [email protected].