2

Context: In long E2E test flows there are certain steps that are duplicated like moving in-between "Product" vs "shipping" vs "Payment method" tabs in an online order workflow.

Problem: In Playwright-Test, duplicate test titles are not allowed as "error" (not as a warning) which is painful for someone who is migrating test scripts from other testing frameworks like "Jasmine" (as in my scenario) where duplicate test titles were allowed.

Desired Solution : Is there a solution, where this error can be avoided on the configuration level (preferably as a warning) without changing 100s of scripts manually? Thanks!

enter image description here

Vishal Aggarwal
  • 1,929
  • 1
  • 13
  • 23

2 Answers2

2

Not sure that you can make it with config, since there is a valid question how you are going to create report in parallel run for non unique test descriptions in playwright...

But one thing you can do, you can make your test unique just by adding some parameter in description. In e.g. test ID, or if tests are data driven, put iterator as pat of the test name.

Or make some wrapper that will overload test method and will add one unique parameter to the test every time.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Gaj Julije
  • 1,538
  • 15
  • 32
  • 1
    Thank you for the answer , however I can make test unique easily by adding even an random number as well but the point s to do in 100s of places in large bulk of scripts. – Vishal Aggarwal May 09 '22 at 12:29
1

Update:

As this has been declined by playwright team to implement, use test.step as workaround.

For new tests: test.step can be re-used in multiple tests, instead of making it a separate test.

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

test('test', async ({ page }) => {
  await test.step('Log in', async () => {
    // ...
  });
});

For existing tests with duplicate titles:

You can write a script to change every test('...', into test('n-...', to make the titles unique by adding a randomely generated long number in the title to make it unique.


A big thank you to Playwright Team , this is being addressed in next release(v1.23) as feature.

https://github.com/microsoft/playwright/issues/13969

Vishal Aggarwal
  • 1,929
  • 1
  • 13
  • 23