Rayrun
← Back to Discord Forum

Test run hanging locally

I've seen an issue this week where the tests appear to be hanging when they get about 3/4 of the way through (of 180 tests). I'm simply trying to get the html output to gather data about the tests but it doesn’t run them all. Is this a common issue? Has anyone any experience of running 100-200 locally & it not crashing? Thanks!

This thread is trying to answer question "Why are the tests hanging when they reach about 3/4 of the way through and how can this be resolved?"

2 replies
cherry_picker_01

does your machine has enough resources to handle the load?

Good question... 🤔 I'm pretty sure it does but should double check. System reqs on playwright.dev don't suggest anymore than the OS version. Any idea what else it recommends as minimum spec?

Answer

Handling Test Hangs with @playwright/test

Running a large number of tests locally can sometimes cause your tests to hang. This can be due to resource limitations, flaky tests, or long-running operations.

Resource Limitations

Your system might not have enough CPU, memory, or network bandwidth to handle a large number of tests. Make sure your machine has enough resources.

Flaky Tests

Flaky tests pass and fail unpredictably. They can cause your tests to hang intermittently. You can identify and fix these tests by analyzing historical data from previous runs or through continuous integration (CI) runs. Check out this blog post for more on handling flaky tests.

Long-Running Operations

If a test waits for an element to appear on the page with no timeout or a long timeout, it can cause the entire test run to hang. Ensure that each action and navigation has reasonable timeouts defined.

import { test } from '@playwright/test';

test('should have reasonable timeouts', async ({ page }) => {
  await page.goto('https://ray.run/');
  await page.waitForSelector('text=Ray', { timeout: 5000 });
});

Best Practices

To ensure smooth execution of your tests, follow these best practices:

  1. Optimize resource allocation: Make sure your machine has enough resources.
  2. Use parallelism wisely: Divide your large suite into smaller subsets and run them in parallel. Check out this blog post for more on parallelism.
  3. Set appropriate timeouts: Define reasonable timeouts for each action and navigation.
  4. Regularly monitor and address flaky tests: Identify and fix flaky tests to reduce test hangs.
  5. Implement proper error handling: Handle exceptions and errors gracefully within your tests.
  6. Use logging and debugging tools: Enable debug logs during test execution to identify any potential issues or errors.

By following these best practices, you can ensure that your testing process is efficient and reliable.

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