Repository navigation
fix(test): read the test.skip, test.fixme, test.fail, and test.slow condition by truthiness - #1964
samanyudas wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 16 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
There was a problem hiding this comment.
0 issues found across 15 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
|
Note 🤖 Claude Sonnet 5.5 responding on behalf of samanyudas Update on the PRs this one waits for (state read from GitHub on 2026-11-22): 2 of 4 have merged, 2 remain. Merged: Remaining (both open, both conflicting with
This PR stays in draft until those two land. It is also conflicting and 81 commits behind Since #1887 has landed, |
michal-e2e
left a comment
There was a problem hiding this comment.
Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.
Hi samanyudas, thanks for this fix and for filing #1966 with a repro first. The bug is still on main, and this PR fixes it in the right place: inside a test body, every two-argument call I ran now behaves as Playwright does.
Reviewed at 189dca9a9 (merge base 19d25806c). Main is now 026d8570d, 259 commits ahead.
The one thing needed before it can merge: a rebase that also covers test.fixme and test.slow.
Must fix
-
Please rebase onto main and move
test.fixmeandtest.slowto the newparseModifierCall(api, args)shape. On main,test.skip,test.fixme,test.failandtest.slowall call the old parser, which still reads any condition that is not a boolean astrue(skip.ts:81on main; callers atregistry.ts:928forfixmeandregistry.ts:947forslow). So after a rebase that only resolves the conflicts,test.fixme(undefined, 'r')still skips andtest.slow(undefined)still triples the timeout. Your comment of 2026-11-22 already plans thefixmemove, which the triage on #1966 asked for.test.slow(#1982) landed after that comment and needs the same move: Playwright 1.65.1 readsslowthe same way as the others, and a falsy condition does nothing.git merge-treeagainst main conflicts inskip.ts,registry.ts,docs/reference/test.mdx,docs/core-concepts.mdxanddocs/migrate/playwright.mdx.Can the rebase add a
test.fixme(undefined, 'r')case that runs the test, and atest.slow(undefined)case that keeps the normal timeout, beside the existingskipandfailones? Please also extend the changeset to namefixmeandslow, and add the two other changes users will see:test.skip('1', 'flaky')now reports the reasonflaky(main reports1), and a lonetest.skip(0)ortest.skip(null)no longer skips.
Optional
-
modifier-call.test.ts:49: the truthiness table runs with no test attempt, soparseModifierCallreturns atskip.ts:57and never reachesskip.ts:63, the line a real test body takes. I changed line 63 so0,null,''andNaNskip again, and all 110 tests in the PR's five test files still passed. Running the two-argument loop inside the file'sinBodyhelper catches it: with that change it fails oncondition: true, and it passes on this commit.it('reads a falsy condition as false in a test body', () => { inBody(() => { for (const falsy of [undefined, null, false, 0, '', Number.NaN]) { expect(parse(falsy, 'flaky on CI')).toEqual(runtime(false, 'flaky on CI')); } }); });
Verified
-
One scratch test file with 21 calls in
apps/testbed, run through the built CLI, results read fromreport.json. "Main's code" is this commit withinternal/skip.ts,collect/registry.tsandmcp/tools.tsput back to19d25806cand rebuilt.Call in the test body main's code this PR test.skip(undefined, 'r'),(null, 'r'),(0, 'r'),('', 'r'),(NaN, 'r')skipped passed test.skip('yes', 'the real reason')skipped [yes]skipped [the real reason]test.fail(undefined, 'gap'), passing bodyfailed UNEXPECTED_PASSpassed test.fail(0, 'gap'), throwing bodypassed as an expected failure failed with the real error test.skip(Promise.resolve(false), 'x'), a thenable object,test.failwith a Promiseskipped, or UNEXPECTED_PASSfailed INVALID_ARGUMENTtest.skip(() => false, 'fn')skipped failed INVALID_ARGUMENTtest.skip(true, 'on'),test.skip(false, 'off'),test.fail(true, 'gap')with a throwing bodyunchanged unchanged test.skip(),test.skip('waiting'),test.skip(undefined),test.skip(''),test.skip(1)skipped skipped test.skip(0)aloneskipped passed -
The PR's five test files at this commit: 110 of 110 pass (
pnpm install,pnpm run build, then vitest onmodifier-call,promise-like,registry,expected-failureandrunner-lifecycle). -
Mutants: nine of ten on the new code in
parseModifierCall,readConditionandisPromiseLikefail one of the PR's tests on an assertion; the tenth survives, which is the optional finding above, and theinBodytest kills it. -
Playwright 1.65.1, read from its published source, not run: inside a test body a falsy condition does nothing for
skip,fixme,failandslow, the reason comes from the second argument, and a function condition throws. This PR matches that for every two-argument call above, except that a Promise fails the test where Playwright skips, which the triage on #1966 agreed to.
Not run
pnpm check, the fullpnpm test, the testbed and the benchmarks at this commit: the rebase rewrites both source files under test, so a run here would not describe what merges. CI was green at this commit.
For the maintainer
- One argument: a lone
undefinedor''still always skips, where Playwright does nothing. TypeScript allows it with no cast, sotest.skip(process.env.CI)skips on every machine. Matching Playwright changes a public overload; a follow-up PR seems the right place. - Patch or breaking: a JavaScript suite with
test.skip(asyncCheck(), 'x')is green today (always skipped) and fails withINVALID_ARGUMENTafter this change. The changeset sayspatch. - Not asked for in the issue:
isPromiseLikenow also counts a function with athenmethod, which reachestest.skipIf,test.runIfanddescribe.test.runIf(Object.assign(() => true, { then() {} }))registered a test before and is aCOLLECTION_ERRORnow. - Of the four PRs this one waits on, #1887 and #1925 merged, #1858 closed without merging, and #1914 is still open. Whether this PR should keep waiting for #1914 is your call.
packages/core/src/types.ts and packages/e2e/tests/types/ are on the public contract list, so the approval is @okwasniewski's.
189dca9 to
b343493
Compare
…ondition by truthiness Inside a test or hook, the four calls counted every condition that was not a boolean as true, so test.skip(process.env.CI, 'x') skipped where CI is unset and test.slow(undefined, 'x') tripled the timeout. Each API now reads the condition by truthiness after its own location check, and a Promise or function condition, always truthy, fails with INVALID_ARGUMENT. Fixes e2e-inc#1966 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b343493 to
0d6c7d0
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of samanyudas Rebased onto main (
The PR body describes the new head, with a |
There was a problem hiding this comment.
Review completed against the latest diff
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
…ws to hooks and fixtures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 1 file (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.
Automated review (AI triage pass), not yet read by a maintainer.
Reviewed b2f843807. In a test body or hook, all four modifiers now read a two-argument condition by truthiness, as Playwright 1.65.1 does. The earlier must-fix is fixed, and I found nothing new that blocks the merge.
Earlier review (michal-e2e at 189dca9a9)
- Must fix (rebase, move
fixmeandslowto the new parser, add tests, extend the changeset): fixed. All four callparseModifierCall(args)(registry.ts:902-941). Each one reads the condition after its own location check (skip.ts:130, expected-failure.ts:46, test-timeout.ts:145). New cases covertest.fixme(undefined, 'only on CI')(runner-lifecycle.test.ts:305) andtest.slow(undefined, 'only on CI'). The changeset names all four APIs, the reason change, and the lonetest.skip(0)change. - The review asked for a lone
test.slow(undefined)that keeps the normal timeout. The PR tests the two-argument form instead. A loneundefinedmatches theslow(reason?)overload and still triples the timeout. That matchesskip, and the PR documents it. See the first maintainer item. - Optional
inBodytable: no longer needed.readRunningConditionis tested directly, and the integration tests cover each call site (mutation M1 below).
Verified
- Merges cleanly into main
b70181b8a. CI is green at the head. pnpm install+pnpm build, then vitest onmodifier-call,promise-like,registry,expected-failure,runner-lifecycleandtest-slow: 130 of 130 pass.- Mutants, each with core or e2e rebuilt. All 8 fail at least one test:
- M1:
condition === falseat theskipRunningTestcall site - M2: the same in
test.fail - M3: the same in
test.slow - M4: the
args.length <= 1guard dropped - M5: the function check dropped
- M6: an objects-only
isPromiseLike - M7: the reason taken from a string first argument again
- M8: the condition read before the location check
- M1:
- Playwright 1.65.1
TestInfo._modifier(from the npm package) returns early onmodifierArgs.length >= 1 && !modifierArgs[0]and takes the description from the second argument. It throws on a function condition in a test body. The PR matches all two-argument calls. It differs in two places: a Promise fails the test withINVALID_ARGUMENT, which the triage on #1966 agreed to, and a loneundefinedor'', which the PR documents. isPromiseLikenow has one shared definition. It behaves the same as the replacedcode-recorder.tsisThenableand the inline checks inreporter-host.tsandtools.ts.
For the maintainer
- A lone
test.skip(undefined)ortest.skip('')still skips (alsofixme,fail,slow), where Playwright does nothing. Sotest.skip(process.env.CI)skips on every machine. The migration guide says to write!!process.env.CI. Matching Playwright means narrowing the public overload: follow-up or never? patchvs breaking: a JS suite withtest.skip(asyncCheck(), 'x')is always skipped today and fails withINVALID_ARGUMENTafter this change.test.skipIfandtest.runIfstill accept a function, which is always truthy, while the running forms now refuse one. Should they refuse it too?packages/core/src/types.tsis on the public contract list. Only the JSDoc changes there; the signatures stay the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix · Severity of issue fixed: Low Merge Risk:
|
|
Note 🤖 Claude Opus 5.5 responding on behalf of samanyudas I merged main ( Git flagged two conflicts in the docs. I resolved them this way:
I checked the merge with these runs at
The four "For the maintainer" questions are still open in the PR body. They are the lone |
michal-e2e
left a comment
There was a problem hiding this comment.
Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.
Reviewed cc0bd6ad9. The rebase and the changes requested in the earlier review are addressed. All four modifiers now share the argument parser. The built CLI reproduced the original problem on the base and confirmed that the new commit lets unset and zero conditions run normally, takes the reason from the second argument, and reports Promise and function conditions as INVALID_ARGUMENT. A lone undefined still takes the unconditional reason overload as documented. Modifier dispatch · Argument parsing
Optional
- The Portuguese Types block still has the old
test.slowdescription. Sync that paragraph with the updated SDK comment or qualify the PR description's claim that the translations carry the same text. Portuguese reference · SDK comment - A rejected, unawaited condition can still fail a later test. I observed that on the base and on this commit. A follow-up could observe the native Promise's rejection when refusing the condition, using the existing matcher as a precedent. Condition reader · Matcher precedent
The public overload signatures still require a boolean for a condition. The target maintainer can decide the release classification for the changed behavior in JavaScript callers. Changeset
Verification
The pinned base and candidate built successfully. The targeted unit and integration suites passed on both revisions when run serially. In the first run, two unchanged tests appended to the same timestamp-named files and failed on both revisions. The serial run eliminated that fixture collision. I found nothing blocking the modifier fix. Release classification and approval remain with the maintainer.
What
In a test body or hook,
test.skip,test.fixme,test.fail, andtest.slownow read their condition by truthiness, as Playwright does.The one-argument reason forms keep e2e's
skip(reason?: string)overload:test.skip(),test.skip('reason'), andtest.skip(undefined)still always skip, and the same holds forfixme,fail, andslow.Why
The four calls counted every condition that was not a boolean as true. So
test.skip(process.env.CI, 'only on CI')skipped on a machine whereCIis unset,test.fail(undefined, 'x')failed a passing test withUNEXPECTED_PASS, andtest.slow(undefined, 'x')tripled the timeout. TypeScript types the condition asboolean, so TypeScript users hit this throughanyor a cast, and JavaScript suites hit it directly. The maintainer asked for the fix in its own PR in #1887.How it works
parseModifierCall(args)(packages/e2e/src/internal/skip.ts) takes the call's own arguments, so a loneskip(undefined)is the reason form andskip(undefined, reason)has a condition. With a condition, the reason is the second argument only. It hands the condition on as given.test.skip,test.fixme,test.fail, andtest.slowall call it asname(...args)(packages/e2e/src/collect/registry.ts).readRunningCondition(packages/core/src/internal/condition.ts) after its own location check, where it used to testif (!condition):skipRunningTest(e2einternal/skip.ts),markRunningTestExpectedToFail(coreinternal/expected-failure.ts), andslowRunningTest(coreinternal/test-timeout.ts). So a misplaced call, such astest.skip(promise, 'x')in abeforeAllhook, keeps main's error, and a call in a test or hook reads the condition by truthiness.readRunningConditionthrowsINVALID_ARGUMENTfor a Promise or a function, since both are always truthy. Playwright throws on a function there too. It builds onreadCondition, the Promise checktest.skipIfandtest.runIfalready used, moved fromregistry.tsto core with the error it throws as a parameter, soskipIfandrunIfkeepCOLLECTION_ERROR.isPromiseLikemoved to core'sinternal/promise-like.tswith its own unit test. It now counts a function with a callablethenas a thenable. The copy inregistry.ts(thedescribebody check),session-tools/code-recorder.ts(isThenable), the inline check inrun/reporter-host.ts, and the MCP schema check insession-tools/tools.tsuse it now. New tests cover the branches no test reached: adescribebody that returns a callable thenable (registry.test.ts), the schema check's lazy schema (mcp-tools.test.ts), and an asynconSummarythat rejects (reporter-stress.test.ts). Core'sagent/tool-loop.tskeeps its own objects-only check: it is the agent loop, and moving it would change which tool results it awaits.reference/test.mdxand theTestAPIJSDoc say "truthy" for all four calls, name the one-argument difference from Playwright, and list the Promise case underINVALID_ARGUMENT. The translatedreference/test.mdxpages carry the same JSDoc in their Types blocks. The Playwright migration guide names the one-argument difference: writetest.skip(!!process.env.CI).Issue
Fixes #1966
Overlap with open PRs
test.skip()from teardown is still open. It conflicts in text only, ininternal/skip.tsandreference/test.mdx, and calls neitherparseModifierCallnorreadConditionin a new place. This PR does not wait for it.For the maintainer
test.skip(undefined)ortest.skip('')still skips, because it matches e2e'sskip(reason?: string)overload. Playwright does nothing on either. Sotest.skip(process.env.CI)skips on every machine. Matching Playwright means narrowing the overload toskip(): void; skip(reason: string): void, which breaks callers that passstring | undefined. I kept today's behavior and documented the difference. A follow-up PR fits that change better.test.skip(asyncCheck(), 'x')is green today, always skipped, and fails withINVALID_ARGUMENTafter this change. The changeset sayspatch.isPromiseLikenow also counts a function with athenmethod. That reachestest.skipIf,test.runIf, anddescribe:test.runIf(Object.assign(() => true, { then() {} }))registered a test before and is aCOLLECTION_ERRORnow.test.skipIf(() => false)still skips at collection, andtest.runIf(() => false)still runs, where the running forms now refuse a function. WhetherskipIfandrunIfshould refuse one too is open.SynchronousCondition<Condition>, asskipIfhas, would lettest.skip(process.env.CI, 'x')type-check. That is a public API change, so it is not in this PR.Verified
Ran it locally: yes
node node_modules/e2e/dist/cli/bin.js run --config <scratch config> --reporter list --workers 1), one scratch test file (not committed), config timeout 1000 ms. The branch column is one run atb3434936c. At the head,cc0bd6ad9(that branch merged with main7c1b2b258), I ran 15 of the table's calls again, with at least one row each forskip,fixme,fail,slow, and thebeforeAllhook. Each result matched its row:origin/maintest.fixme(process.env.UNSET, 'only on CI')[fixme: only on CI]test.fixme(0, 'no items')[fixme: no items]test.fixme('yes', 'the real reason')[fixme: yes][fixme: the real reason]test.fixme(Promise.resolve(false), 'async check')[fixme: async check]test.fixme() got a Promise as its condition; await it before the calltest.fixme(true, 'crashes on webkit'),test.fixme()test.slow(process.env.UNSET, 'only on CI'), 1500 ms bodytest.slow(null), 1500 ms bodytest.slow(true, 'large import'),test.slow(), 1500 ms bodytest.slow(Promise.resolve(false), 'async check')test.slow() got a Promise as its condition; await it before the calltest.slow(Promise.resolve(true))inbeforeAllHOOK_FAILED:beforeAll failed: test.slow() got a Promise as its condition; await it before the calltest.skip(Promise.resolve(false), 'x')andtest.fail(...)inbeforeAllHOOK_FAILED:... must be called inside a test body(read from main's code)test.skip(process.env.UNSET, 'only on CI'),test.fail(process.env.UNSET, 'gap')with a passing bodyUNEXPECTED_PASS(from the maintainer's review)test.skip(() => false, 'fn')test.skip() got a function as its condition; call it and pass the resulttest.skip(0)alonetest.skip('1', 'flaky')[1][flaky]mainrows come from anorigin/main(aaf923188) build running the same calls. On main,skipRunningTestandmarkRunningTestExpectedToFailcheck the location before the condition, so abeforeAllcall fails there whatever the condition is.condition !== falsefailsmodifier-call.test.ts.beforeAlltest forskip, and the new outside-a-testtest.slow(Promise)case forslow.skipRunningTest, or after the serial-member check inmarkRunningTestExpectedToFail, fails the new setup and serial cases.condition === falseintest.failortest.slow, or letting a function through intest.slow, failsexpected-failure.test.tsortest-slow.test.ts.isPromiseLikefailsregistry.test.ts. Dropping the lazy-schema branch failsmcp-tools.test.ts. Never adopting an asynconSummaryfailsreporter-stress.test.ts.cc0bd6ad9,pnpm checkpassed, and so did the PR's test files:modifier-call,promise-like,registry,expected-failure(unit and integration),test-slow,mcp-tools,runner-lifecycle, andreporter-stress(169 of 169). The fullpackages/e2esuite passed 6718 of 6719 atb3434936c, before the merge. The one failure there,step-hold.test.ts("fails a held step the body never awaited, and lets its hold go"), does not touch this change and passed 5 of 5 runs alone.🤖 Generated with Claude Code
Summary by CodeRabbit
skip,fixme,fail, andslowmodifiers now act on truthy conditions; falsy conditions leave the test unchanged.INVALID_ARGUMENT. Resolve promises or call functions before passing their results as conditions.slow, which does not report a reason.failcannot be applied to setup tests or serial-group members.