Skip to content

Issue with playwright/valid-title with string variable test name in loop or read from cases array #368

@gdarchen

Description

@gdarchen

Hello,

I noticed an issue with the playwright/valid-title rule when the test name comes from a string variable inside of a loop or read from a cases array.

Here is an example:

type TestCase = {
  name: string;
  // ...
};

const cases: TestCase[] = [
  {
    name: 'my first test',
    // ...
  },
  {
    name: 'my second test',
    // ...
  },
];

test.describe('Tests with loop', () => {
  for (const { name } of cases) {
    test(name, async () => {
      // ...
      expect(1 + 1).toBe(2);
    });
  }
});

It wrongly complains that the title is expected to be a string, which is actually the case.

Image

We have the same issue when reading from the cases array instead of looping.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions