playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] run tests only against changed files

Open SimonGolms opened this issue 2 years ago • 12 comments

Description

As a user, I want to run my component tests only on changed files, as it would be a use case in a git hook (pre-push)

Alternatives

  • https://jestjs.io/docs/cli#--onlychanged
  • https://vitest.dev/guide/cli.html#changed

Preferred Solution

Enhancement of the cli commands, e.g.

npx playwright test --only-changed

SimonGolms avatar Jun 23 '22 14:06 SimonGolms

I propose something inspired by Vitest, that can check for uncommited changes, or changes compared to a commit.

npx playwright test --changed
npx playwright test --changed d819f97f40386c9bd31a53525240c6e9997a10f4
npx playwright test --changed main

What do you think ?

jfgreffier avatar Nov 27 '22 20:11 jfgreffier

WIP, I just pushed documentation

jfgreffier avatar Dec 01 '22 20:12 jfgreffier

The PR is completed since a while. Waiting for feedback and review.

jfgreffier avatar Dec 16 '22 13:12 jfgreffier

I think the missing piece is running the tests for the modified components.

pavelfeldman avatar Dec 19 '22 23:12 pavelfeldman

The PR is completed since a while. Waiting for feedback and review.

I saw the PR was closed. Any chance of re-opening and taking a look at this again? It's something that would greatly benefit our team

joeflan avatar Mar 14 '23 15:03 joeflan

what's the status here? opened but not merged. can someone have a look? it seems like a pretty nice feature.

y-nk avatar Apr 03 '23 05:04 y-nk

@pavelfeldman - Looks like you had feedback before closing the PR. Is there any direction? My team is blocked on merging tests due to untouched tests failing.

sayers24 avatar Aug 07 '23 21:08 sayers24

Waiting for this so much. Do you have it in your roadmap?

max-mykhailenko avatar Sep 21 '23 14:09 max-mykhailenko

This would be helpful for our organization. We don't need to run tests on stories that haven't changed. Any updates on this feature?

visualjeff avatar Oct 14 '23 03:10 visualjeff

This would be awesome for my team!

maxfieldegaj avatar Nov 14 '23 16:11 maxfieldegaj

Also would like this too, having moved from Selenium to Playwright, this would be a huge feature. It is easy to fetch changed *.spec.ts files with git via some cli stuff, but also having it just built in, with support for also identifying used objects to determine what tests to run would be amazing.

Proryanator avatar Mar 14 '24 18:03 Proryanator

Also would like this too, having moved from Selenium to Playwright, this would be a huge feature. It is easy to fetch changed *.spec.ts files with git via some cli stuff, but also having it just built in, with support for also identifying used objects to determine what tests to run would be amazing.

Problem is this feature requires two options / implementations which is more complex than just parsing git diff. One option to run changed tests based on test code change, another is to run tests based on, for example, component code changes like what Jest is doing with --only-changed option.

MindaugasMateika avatar Mar 14 '24 18:03 MindaugasMateika