Playwright Control Test Order

In this article, we will see how we can control test order in playwright. Unless we parallelize tests in a single file, the playwright runs tests from a single file in order of declaration.

Playwright runs tests in parallel by default, and there is no guarantee about the order of execution. If we disable parallel execution, we can control the order of execution by test file naming in alphabetical order or using a test file list.


  • After disabling parallel execution, playwright tests now run in alphabetical order.
  • Certain naming conventions can be followed, for example: 
    001-signin.spec.ts, 002-create-User.spec.ts

Test List File:

// feature-a.spec.js
const { test, expect } = require('@playwright/test');
module.exports = function createTests() {
 test('feature-a test', async ({ page }) => {
   // ... text goes here

// feature-b.spec.js
const { test, expect } = require('@playwright/test');
module.exports = function createTests() {
 test.use({ viewport: { width: 500, height: 500 } });
 test('feature-b test', async ({ page }) => {
   // ... text goes here
  • We can use a test list file that will easily control the test's order.
  • Test.use() affects only tests from a single file.
  • This will run feature-b tests and then feature-a tests.

After creating the tests, do this.

const { test } = require('@playwright/test');

Now disable parallel execution, set workers to one, and specify the test list file.

const config = {
 workers: 1,
 testMatch: 'test.list.js',
module.exports = config;
Mon, 01/09/2023 - 13:51
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.