Rayrun

How do I change the default test timeout in Playwright Test configuration file?

Answer

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:

  1. Locate or create the playwright.config.ts file in your project directory.

  2. 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.

Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

TwitterGitHubLinkedIn
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 [email protected].