javascriptautomated-testsplaywrightplaywright-test

How to avoid "Duplicate test titles are not allowed" error in playwright-test?


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


Solution

  • This is how I am currently handling - tried & tested solution:

    const uniqueId= () => Date.now() - Math.floor(Math.random()*1000)
    
    test("Import User" + uniqueId(), async () => {
      //import user 1
    })
    
    test("Import User" + uniqueId(), async () => {
      //import user 2
    })
    
    test("Import User" + uniqueId(), async () => {
      //import user 3
    })