Repository navigation
feat(test): add test.describe.only and the only option on describe - #2049
Akarshkushwaha wants to merge 2 commits into
Conversation
A test inside a focused group is registered with the same `only` mode `test.only` sets, so the existing focus rules and the CI rejection (ONLY_IN_CI) apply unchanged. The innermost `only` wins, so `only: false` on an inner group or a test opts it out, and a skipped test or group stays unfocused and filtered, as beside `test.only`. A serial group can be focused whole; `only` inside one is refused. Part of e2e-inc#1855. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
The ja and zh reference pages now translate the describe.only section and its Throws table, keeping the code as in English. The describe bullet no longer says a group takes every option except only, in all three languages, and the Playwright "not yet" row drops its trailing test.only clause, which pointed at describe.only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 6 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Reviewed at faee11c against main c30354f, compared with #1925 (describe.fail) and Playwright 1.65.1 filterOnly. The claim on #1855 is yours and the shape mirrors describe.fail. No peer floor needed: e2e and @e2e-dev/core are a fixed changeset group, and engines never see DescribeOptions. The PR is mergeable (clean), CI is 26 success + 4 skipped.
Must fix
-
packages/e2e/src/collect/registry.ts:421(focusedByGroup) plus themode === 'normal'gate at:250: a focused group whose tests are all skipped, or adescribe.onlyinside a skipped group, focuses nothing. The rest of the suite then runs and CI no longer rejects the.only. Atest.onlyin the same spot keeps the focus and fails CI. I ran both againstselect():test('other'); describe('g', { skip: 'broken' }, () => test.only('x')):otherfiltered,xskipped, CI throwsONLY_IN_CI(main behavior)test('other'); describe('g', { skip: 'broken' }, () => describe.only('f', () => test('x'))):otherruns, CI passestest('other'); describe.only('f', () => test.skip('s')):otherruns, CI passes
So someone who focuses a group to debug it, while its tests are fixme'd, gets the whole suite instead. A committed
describe.onlyalso gets past CI, which breaks the PR's own "the existing focus rules and the CI rejection apply unchanged". The root cause is thatTestModepacks focus and skip kind into one enum, so a test cannot be both focused and fixme. That is why the skip special case exists, and whyselect.ts:723readsmode === 'fixme'for the skip cause. Suggested fix: put focus in its own field.RegisteredTest/CollectedTestgetfocused: boolean, set once inregisterTesttooptions.only ?? innermost group only.modekeeps onlynormal | skip | fixme, andselect.ts:332/:645readtest.focused. Then a skipped test in a focused group is reportedskippedwith its real cause, astest.onlyin a skipped group already is and as Playwright does. The ternary at:250and the skip walk infocusedByGroupgo away. This also fixestest.fixme(title, { only: true }, fn), which reports causeexpliciton main today. Update the docs bullet atdocs/reference/test.mdx:470and the tests that assertfilteredfor skipped tests inside a focused group.
Should fix
- Nested focus differs from Playwright, but the migrate row says "the same". In Playwright,
describe.only('f', () => { test('x'); test.only('y') })runs onlyy, because the inner focus narrows. Vitest does the same. Here both run, andonly: falseexists to opt tests back out. Either narrow like Playwright, which makes group-levelonly: falseunnecessary, or keep the union and say in the migrate row that an innertest.onlydoes not narrow a focused group. That one is a maintainer call. docs/migrate/cypress.mdx:129still listsdescribe.onlyunder "What e2e doesn't have yet" with the workaround "test.onlyon each test". Move it to the mapped table.
Nits
packages/core/src/types.ts:1066: thedescribeJSDoc onTestAPInames onlydescribe.fail. Mentiondescribe.onlytoo, along with the copy indocs/reference/test.mdx:1237.- An empty
describe.onlyregisters no focused tests, so CI does not flag it. Playwright'sforbidOnlydoes. This is minor, and thefocusedfield above does not change it. Fine to leave.
Verified
tests/unit/registry.test.ts+tests/unit/select.test.ts: 119 passed.tests/integration/describe-only.test.ts: 2 passed, on built core/e2e/web.tsc --noEmitand oxlint on the changed files are clean.- I made 6 mutants in
registry.tsand the tests caught all of them: dropping the testonly: falseopt-out, dropping the skipped-group check, dropping the serial-inside refusal, any-onlyinstead of innermost, dropping "describe.only takes no only", and dropping the boolean check. - I reproduced the three cases above with a temporary
select()probe. Adescribe.onlyaround a serial group under--grepkeeps the serial closure, which is fine. - cubic's 7 doc findings are fixed in faee11c.
registry.tsis at 966 lines, under the cap.types.tswas already over 1000 before this PR.
|
🤖 Claude Opus 5.5 responding on behalf of KrzysztofMoch Closing in favor of #2244, which carries this work forward. Your two commits are in it, rebased onto main with your authorship kept, @Akarshkushwaha. On top of them, #2244 fixes three issues found in review:
Thanks for the contribution. |
What and why
test.describe.only(title, fn)and theonlyoption ondescribe, thetest.describe.only('checkout', fn)item of ☂️ Help us bring missing APIs to e2e #1855.onlymodetest.onlysets (packages/e2e/src/collect/registry.ts), so the existing focus rules and the CI rejection (ONLY_IN_CI) apply unchanged.onlywins:only: falseon an inner group or a test opts it out. A skipped test or group stays unfocused andfiltered, as besidetest.only.onlyinside one is aCOLLECTION_ERROR.Issue
Part of #1855 (
test.describe.only('checkout', fn), assigned to me).Verified
Ran it locally: yes
describe.only('checkout')group with a nested group, and another unfocused group.COLLECTION_ERROR:describe.only is not a functioncheckoutrun, nested one included; the rest are filteredCI=1:ONLY_IN_CItests/integration/describe-only.test.ts(focused groups beside atest.only, andONLY_IN_CI), plus unit tests inregistry.test.tsandselect.test.ts.describe.onlysection in English, as they do fordescribe.fail; the surrounding sentences and the migrate rows are translated.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.🤖 Generated with Claude Code