Skip to content

[Feature] Simple and elegant data driven parameterized tests #22295

@NikkTod

Description

@NikkTod

Hello Playwright team, currentlly for passing parameters in tests we can use 'for loop'.

// example.spec.ts
const people = ['Alice', 'Bob'];
for (const name of people) {
  test(`testing with ${name}`, async () => {
  });
}

We tent to use multiple params and I was wondering if it is possible to have more elegant and easy to read representation like we have for example in other test runners:

NUnit:

[TestCase(10,10,10,90)]
[TestCase(10,10,0,100)]
public void testCalculate(double price,int quantity,double discount,double expectedFinalAmount) {...}

Cucumber:

Scenario Outline:  Test Name
 Examples:
    | start | eat | left |
    |  12   |   5  |   7   |
    |  20   |   5  |  15  |

Jest

test.each`
  a    | b    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${1} | ${3}
`('returns $expected when $a is added to $b', ({a, b, expected}) => { expect(a + b).toBe(expected); });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions