microsoft / microsoft/playwright
[BUG]: --last-failed silently drops all tests when using project dependencies
@dgozman is already working on this.
Since Mar 24, 2026.
- Dominant language
- TypeScript
- Stars
- 96.3k
- Forks
- 6.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 180
Description
## Bug description
`--last-failed` silently results in "No tests found" when the config uses project `dependencies`. Tests from dependency projects are never checked against the `--last-failed` filter and are excluded entirely.
## Reproduction
**playwright.config.ts:**
```ts
export default defineConfig({
testDir: '.',
projects: [
{
name: 'default',
testIgnore: /setup/,
},
{
name: 'sequential',
testMatch: /setup/,
dependencies: ['default'],
},
],
});
```
**Steps:**
1. Run tests — some in the `default` project fail
2. Run `npx playwright test --last-failed`
3. Result: `Error: No tests found` — even though `.last-run.json` contains valid failed test IDs
## Root cause
In `runner/loadUtils.js`, the `postShardTestFilters` (used by `--last-failed`) is applied on **line 173-174**, but dependency projects are only added to `rootSuite` later on **line 179-180**:
```js
// Line 145-151: Only "top-level" projects are added to rootSuite
const projectClosure = buildProjectsClosure([...filteredProjectSuites.keys()], ...);
for (const [project, type] of projectClosure) {
if (type === "top-level") {
rootSuite._addSuite(buildProjectSuite(project, ...));
}
}
// Line 173-174: postShardTestFilters runs — but rootSuite only has top-level projects
if (config.postShardTestFilters.length)
filterTestsRemoveEmptySuites(rootSuite, (test) => config.postShardTestFilters.every((filter) => filter(test)));
// Line 177-183: Dependency projects are added AFTER the filter already ran
const projectClosure2 = new Map(buildProjectsClosure(rootSuite.suites.map(...)));
for (const [project, level] of projectClosure2.entries()) {
if (level === "dependency")
rootSuite._prependSuite(buildProjectSuite(project, projectSuites.get(project)));
}
```
When `default` is a dependency of `sequential`:
1. Only `sequential` tests are in `rootSuite` when `postShardTestFilters` runs
2. The failed test IDs (from `default` project) don't match any `sequential` test IDs
3. All `sequential` tests are filtered out → "No tests found"
4. `default` project tests are added afterward but were never filtered — they just get added in full (but since all top-level tests were removed, the suite is empty)
## Confirmed via instrumentation
Added debug logging to `LastRunReporter.filterLastFailed()`:
```
[DEBUG] failedTestIds: ["44ee58bcb63fdfc96a27-8cbdbefff5ceb59d5a64", ...]
[DEBUG] no match: test.id=c540d76cbc29c39320a1-39d5ca1a35c64343e96a title=Toggle visible in header
```
The `44ee58bc...` prefix = `default` project's file hash. The `c540d76c...` prefix = `sequential` project's file hash. Only `sequential` tests are checked; `default` tests are never seen by the filter.
## Expected behavior
`--last-failed` should filter tests from ALL projects (including dependencies), not just top-level projects.
## Suggested fix
Move the `postShardTestFilters` application to after dependency projects are added to `rootSuite`, or apply the filter to all project suites before the closure is built.
## Version
- Playwright: 1.58.2
- OS: Windows 10
- Node.js: 24.14.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.