playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: --last-failed doesn't respect --project filter

Open agoldis opened this issue 11 months ago • 1 comments

Version

1.52.0

Steps to reproduce

An example is available at https://github.com/agoldis/playwright-issue-last-failed-multiple-projects

--

Given two projects: a and b

  • each has a different output dir test-results/a and test-results/b
  • each has 1 test file, 2 tests (1 passing and 1 failing)
# Initial - run two projects, all tests
$ npx playwright test

Running 4 tests using 1 worker

  ✘  1 [a] › a.spec.ts:3:5 › a-001 (5ms)
  ✓  2 [a] › a.spec.ts:7:5 › a-002 (4ms)
  ✓  3 [b] › b.spec.ts:3:5 › b-001 (5ms)
  ✘  4 [b] › b.spec.ts:7:5 › b-002 (3ms)

# Next run, filter by project b, only previously failed tests
# ❌ should run only 1 failed test
$ npx playwright test --last-failed --project b

Running 2 tests using 1 worker

  ✓  1 [b] › b.spec.ts:3:5 › b-001 (4ms)
  ✘  2 [b] › b.spec.ts:7:5 › b-002 (3ms)

Expected behavior

I think --last-failed should respect --project filter.

Actual behavior

--last-failed doesn't respect --project filter.

Additional context

Looking at https://github.com/microsoft/playwright/blob/ed5c3b91015021b9ff2f729b343aa08c11d90005/packages/playwright/src/runner/lastRun.ts#L31 .last-run.json is always persisted in the first project's output dir, changing the projects scope reveals the issue.

Would be happy to contribute a fix or a documentation update if it's an expected behaviour.

Environment

System:
    OS: macOS 15.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 246.89 MB / 32.00 GB
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.9.0 - /opt/homebrew/bin/npm
    pnpm: 10.6.3 - ~/Library/pnpm/pnpm
    bun: 1.1.2 - ~/.bun/bin/bun
  IDEs:
    VSCode: 1.99.3 - /usr/local/bin/code
  Languages:
    Bash: 3.2.57 - /bin/bash
  npmPackages:
    @playwright/test: ^1.52.0 => 1.52.0

agoldis avatar May 10 '25 07:05 agoldis

+1

Danieliverant avatar Jun 24 '25 15:06 Danieliverant