Repository navigation
feat(test-runner): add Reporter.preprocessSuite() hook for test filtering - #41100
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Simon Knott (@Skn0tt) Sweet, we'd love to dogfood this once it lands! We implemented time-based sharding using the A few comments:
|
Add tests locking in that Reporter.plan's suite contains only top-level projects (setup/dependency projects are not exposed), respects --project and --grep, and ignores --shard (built-in sharding runs after plan). Clarify the Reporter.plan.suite docs accordingly. Fixes: microsoft#40934
|
Thanks for the feedback. Sounds like what you have in mind is already there, i've added tests and extended docs to capture that. The API does allow excluding projects, but not project dependencies. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| const shardingReporters = reporters.filter(r => r.implementsSharding?.() ?? false); | ||
| if (shardingReporters.length > 1) | ||
| throw new Error(`Multiple reporters declare 'implementsSharding': ${shardingReporters.map(r => r.constructor?.name ?? 'reporter').join(', ')}. Only one reporter may handle sharding.`); |
There was a problem hiding this comment.
Not sure why this is an issue, let them plan as much as they want?
There was a problem hiding this comment.
All shards need to receive the same input tree, but if there's two reporters implementing sharding, then the second one will receive different inputs per shard. So for the same reason that our sharding cannot run together with 3rd party sharding, two 3rd party sharders cannot run together.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| skip(reason?: string): void { | ||
| for (const entry of this.entries()) | ||
| entry.skip(reason); |
There was a problem hiding this comment.
I prefer this to be on the suite itself, like we have Suite._staticAnnotations. Can we do that?
There was a problem hiding this comment.
I gave this a go, but we'd need to also mirror it somehow into entry.annotations so that following reporters can see the applied annotations. I'll keep it as is for now, happy to discuss this more.
Capture the caller location for Suite/TestCase skip/fixme/fail via wrapFunctionWithLocation, matching TestInfo. Suite dispositions cascade eagerly to descendant tests, so a later reporter observes an earlier reporter's Suite.skip. Rename the spec to reporter-preprocess-suite.
Test results for "MCP"1 failed 7460 passed, 1132 skipped Merge workflow run. |
Test results for "tests 1"2 flaky49399 passed, 1163 skipped Merge workflow run. |
Adds a
Reporter.plan(rootSuite)hook that runs betweenonConfigureandonBegin, letting reporters filter/modify tests usingskip/fixme/fail/excludedisposition methods onTestCaseandSuite.Reporters can also opt out of Playwright's built-in sharding by implementing
implementsSharding().Follow-up: expose
Suite.parallelModepublicly so third-party sharders can keeptest.describe.serial(...)chains together. Without it, custom sharding can only safely split tests that aren't in serial groups.Fixes #40934