Skip to content

Add split-by-example support for Playwright#443

Open
jeffal wants to merge 2 commits intobuildkite:mainfrom
jeffal:playwright-split-by-example
Open

Add split-by-example support for Playwright#443
jeffal wants to merge 2 commits intobuildkite:mainfrom
jeffal:playwright-split-by-example

Conversation

@jeffal
Copy link
Copy Markdown

@jeffal jeffal commented Feb 13, 2026

Implement GetExamples() for the Playwright runner to enable splitting slow test files by individual test example.

Uses playwright test --list --reporter=json to enumerate tests without running them, similar to how RSpec uses --dry-run and pytest uses --collect-only.

@jeffal jeffal requested a review from a team as a code owner February 13, 2026 05:41
@jeffal
Copy link
Copy Markdown
Author

jeffal commented Feb 17, 2026

Hi @niceking, I fixed the failing tests.

// [Buildkite Test Collector - Playwright implementation](https://github.com/buildkite/test-collector-javascript/blob/42b803a618a15a07edf0169038ef4b5eba88f98d/playwright/reporter.js#L47)
// [Playwright titlePath implementation](https://github.com/microsoft/playwright/blob/523e50088a7f982dd96aacdb260dfbd1189159b1/packages/playwright/src/common/test.ts#L126)
// [Playwright suite structure](https://playwright.dev/docs/api/class-suite)
func mapSpecToTestCase(spec PlaywrightSpec, suiteName string) plan.TestCase {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is copied/extracted from lines 97-108. Could we replace those lines with this new function so we don't have duplicate?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. getTestResultsFromSuite now calls mapSpecToTestCase.

Comment thread internal/runner/playwright_test.go Outdated
changeCwd(t, "./testdata/playwright")

playwright := NewPlaywright(RunnerConfig{
// Use npx directly because yarn adds prefix output to stdout that corrupts JSON parsing
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user sets a custom command to use yarn? Will the getExamples function fail?

I think we should handle the case where user use yarn. Can we save the json output to a temporary file and parse that file instead of reading the raw stdout

https://playwright.dev/docs/test-reporters#json-reporter

Copy link
Copy Markdown
Author

@jeffal jeffal Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The json output now goes to a temp file via PLAYWRIGHT_JSON_OUTPUT_NAME env var, bypassing stdout entirely.

@nprizal
Copy link
Copy Markdown
Contributor

nprizal commented Feb 19, 2026

Thanks for opening the PR @jeffal, it looks good overall. The only issue is that parsing the stdout with yarn will fail.

@nprizal
Copy link
Copy Markdown
Contributor

nprizal commented Apr 13, 2026

Hi @jeffal, just checking if you had a chance to look at the issue I posted?

jeffal added 2 commits April 17, 2026 00:17
Implement GetExamples() for the Playwright runner using
`playwright test --list --reporter=json` to enumerate tests
without running them.
@jeffal jeffal force-pushed the playwright-split-by-example branch from c021cd0 to 7afe3aa Compare April 17, 2026 05:25
@jeffal
Copy link
Copy Markdown
Author

jeffal commented Apr 17, 2026

Hi @jeffal, just checking if you had a chance to look at the issue I posted?

Sorry for the delay! Both issues are addressed and I've rebased on latest main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants