Skip to content

feat(playwright): stop tracing the happy path, report slow tests - #2

Merged
nk-o merged 1 commit into
mainfrom
claude/ci-e2e-overhead
Aug 11, 2026
Merged

feat(playwright): stop tracing the happy path, report slow tests#2
nk-o merged 1 commit into
mainfrom
claude/ci-e2e-overhead

Conversation

@nk-o

@nk-o nk-o commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Why

Two settings in the shared Playwright preset were costing every consuming plugin time, and a third gap meant nothing checked this repo before publish.

trace: 'retain-on-failure''on-first-retry'

retain-on-failure records a trace for every test and deletes it when the test passes. A green suite therefore pays the full tracing cost — DOM snapshots around every action — to keep artefacts for the tests that fail. Since retries: process.env.CI ? 2 : 0 already retries anything that fails under CI, on-first-retry produces the same artefacts where they are useful and none of the overhead where they are not.

reportSlowTests: null{ max: 5, threshold: 30_000 }

This is the report that tells you a suite has gone wrong, and it was switched off. Concretely, measured across the plugin family last week:

suite tests time s/test
visual-portfolio 56 9.7m 10.4
visual-portfolio-pro (core suite) 56 12.0m 12.9
visual-portfolio-pro (Pro suite) 131 10.2m 4.7
lazy-blocks 26 1.9m 4.4
ghostkit 24 1.7m 4.2

The visual-portfolio core suite is ~2.4x slower per test than every sibling — including a 131-test suite on the same runner in the same job. The cause turned out to be a beforeEach doing a full page.goto('/wp-admin/') before each of 28 tests purely to read window.VPAdminVariables.nonce, while the tests themselves only issue page.request.post. A slow-test report would have named that file the first time it ran.

CI on pull requests

npm-publish.yml runs on v* tags and workflow_dispatch only, so no workflow ran on a pull request. A regression could only be caught once it was already on its way to npm. The new ci.yml runs the same lint + test pair the publish job gates on, before the merge instead of after the tag. It stays on ubuntu-latest — this repo is public, so those minutes are free.

Verification

Both new settings are covered by scripts/self-test.js, matching how navigationTimeout is guarded:

  • tracing is not paid for on the happy path — asserts trace === 'on-first-retry' and that retries > 0, since the setting only produces artefacts if failures are actually retried.
  • slow tests are reported — asserts reportSlowTests is not null and that the threshold is non-zero.

npm run lint and npm test pass locally (12 checks).

Version

0.6.0, not a patch. Both changes alter behaviour for every consumer, and consumers pin ^0.5.1, so picking this up should be a deliberate bump on their side rather than something that arrives silently.

`trace: 'retain-on-failure'` records a trace for every test and throws it
away when the test passes, so a fully green suite pays the tracing cost
in full to keep artefacts for the tests that fail. `on-first-retry` moves
that onto the retry, which `retries: 2` already guarantees under CI --
the same artefacts where they are useful, none of the overhead where they
are not.

`reportSlowTests: null` silenced Playwright's slow-test summary. That
report is how you notice a suite going wrong: visual-portfolio has been
running 56 tests at 10.4s each against 4.2-4.7s for every sibling suite,
because a `beforeEach` loads the whole of wp-admin before each test to
read one string. Nothing surfaced it for months. Restored at Playwright's
default shape with a 30s threshold.

Adds a CI workflow too. Only npm-publish existed, and it runs on tags, so
until now nothing checked a pull request -- a change could only fail once
it was already on its way to npm. Same lint + test pair, run before the
merge.

Minor rather than patch: both settings change behaviour for every
consumer, and consumers pin ^0.5.1, so the bump has to be deliberate on
their side.
@nk-o
nk-o merged commit 007907d into main Aug 11, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a017f7636

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include the pull request identity in the concurrency group

For pull requests from forks, github.head_ref contains only the source branch name, so unrelated contributors using a common name such as main or fix receive the same concurrency group. Starting CI for one of those PRs will therefore cancel the in-progress verify job for the other; use the PR number, github.ref, or include the head repository owner to make the group unique per PR.

Useful? React with 👍 / 👎.

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.

1 participant