Rayrun

What is the execution order of tests under test.describe() in @playwright/test?

Answer

Sure, tests under test.describe() in @playwright/test run in the order they're defined. Let's say you have a group "two tests" with tests "one" and "two". "One" will always run before "two" because it's defined first.

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

test.describe('two tests', () => {
  test('one', async ({}) => {
    // Test one code here
  });

  test('two', async ({}) => {
    // Test two code here
  });

});

If you use test.describe.serial(), tests run one after another. If a test fails, the rest are skipped. They're also retried together.

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

test.describe.serial('two tests', () => {
  test('one', async ({}) => {
    // Test one code here
  });

  test('two', async ({}) => {
    // Test two code here
  });

});

For concurrent execution, use test.describe.parallel(). But, it's better to use test.describe.configure() for execution modes.

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

test.describe.parallel('two tests', () => {
  test('one', async ({}) => {
    // Test one code here
  });

  test('two', async ({}) => {
    // Test two code here
  });

});

You can also use test.describe() for an anonymous group of tests. This is handy for giving a common option to a set of grouped tests with test.use().

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

test.describe('two tests', () => {
  test.use({ baseURL: 'https://ray.run' });

  test('one', async ({}) => {
    // Test one code here
  });

  test('two', async ({}) => {
    // Test two code here
  });

});

References

Thank you!
Was this helpful?
Still have questions?

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

Related Questions

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