Rayrun

What is the reason for the afterAll hook taking 1.5 minutes to complete in my Playwright test report?

Answer

The afterAll hook in @playwright/test might take 1.5 minutes to complete due to several reasons:

  1. Time-consuming operations: If there are many workers or fixtures to be torn down, it could take longer to complete their tasks.
import { test } from '@playwright/test';

test.afterAll(async () => {
  // Time-consuming teardown tasks
});
  1. Timeout settings: The afterAll hook has a separate timeout that can be changed using testInfo.setTimeout(). If the timeout is set too high or too low, it could cause delays.
import { test } from '@playwright/test';

test.afterAll(async ({ testInfo }) => {
  testInfo.setTimeout(60000); // Set the timeout to 60 seconds
  // Teardown tasks
});
  1. Global timeout: Playwright Test supports a global timeout for the entire test run. If it's set too low and there are many tests with complex setup/teardown requirements, it could cause issues with completing the afterAll hook within the expected time.
import { test } from '@playwright/test';

test.setTimeout(120000); // Set the global timeout to 2 minutes

To avoid unexpected delays in your test runs, review your code carefully and ensure you're using appropriate timeouts at each level.

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 luc@ray.run.