Skip to content

fix(test): read the test.skip, test.fixme, test.fail, and test.slow condition by truthiness - #1964

Open
samanyudas wants to merge 4 commits into
e2e-inc:mainfrom
samanyudas:fix/modifier-falsy-condition
Open

samanyudas wants to merge 4 commits into
e2e-inc:mainfrom
samanyudas:fix/modifier-falsy-condition

Conversation

@samanyudas

@samanyudas samanyudas commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

In a test body or hook, test.skip, test.fixme, test.fail, and test.slow now read their condition by truthiness, as Playwright does.

test('sync', async () => {
  test.skip(process.env.CI, 'flaky on CI');  // CI unset: runs (main: skipped)
  test.fixme(flags.beta, 'beta crash');       // flag missing: runs (main: skipped as fixme)
  test.fail(flags.beta, 'beta gap');          // flag missing: runs as normal (main: UNEXPECTED_PASS)
  test.slow(process.env.CI, 'slow CI');       // CI unset: normal timeout (main: tripled)
  test.skip('1', 'flaky');                    // skipped with reason "flaky" (main: reason "1")
  test.skip(0);                               // runs (main: skipped)
  test.skip(isSingleTenant(), 'x');           // missing await: INVALID_ARGUMENT (main: always skipped)
  test.skip(() => isBeta, 'x');               // a function: INVALID_ARGUMENT (main: always skipped)
});

The one-argument reason forms keep e2e's skip(reason?: string) overload: test.skip(), test.skip('reason'), and test.skip(undefined) still always skip, and the same holds for fixme, fail, and slow.

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 where CI is unset, test.fail(undefined, 'x') failed a passing test with UNEXPECTED_PASS, and test.slow(undefined, 'x') tripled the timeout. TypeScript types the condition as boolean, so TypeScript users hit this through any or a cast, and JavaScript suites hit it directly. The maintainer asked for the fix in its own PR in #1887.

How it works

  1. parseModifierCall(args) (packages/e2e/src/internal/skip.ts) takes the call's own arguments, so a lone skip(undefined) is the reason form and skip(undefined, reason) has a condition. With a condition, the reason is the second argument only. It hands the condition on as given.
  2. test.skip, test.fixme, test.fail, and test.slow all call it as name(...args) (packages/e2e/src/collect/registry.ts).
  3. Each API reads the condition with readRunningCondition (packages/core/src/internal/condition.ts) after its own location check, where it used to test if (!condition): skipRunningTest (e2e internal/skip.ts), markRunningTestExpectedToFail (core internal/expected-failure.ts), and slowRunningTest (core internal/test-timeout.ts). So a misplaced call, such as test.skip(promise, 'x') in a beforeAll hook, keeps main's error, and a call in a test or hook reads the condition by truthiness.
  4. readRunningCondition throws INVALID_ARGUMENT for a Promise or a function, since both are always truthy. Playwright throws on a function there too. It builds on readCondition, the Promise check test.skipIf and test.runIf already used, moved from registry.ts to core with the error it throws as a parameter, so skipIf and runIf keep COLLECTION_ERROR.
  5. isPromiseLike moved to core's internal/promise-like.ts with its own unit test. It now counts a function with a callable then as a thenable. The copy in registry.ts (the describe body check), session-tools/code-recorder.ts (isThenable), the inline check in run/reporter-host.ts, and the MCP schema check in session-tools/tools.ts use it now. New tests cover the branches no test reached: a describe body that returns a callable thenable (registry.test.ts), the schema check's lazy schema (mcp-tools.test.ts), and an async onSummary that rejects (reporter-stress.test.ts). Core's agent/tool-loop.ts keeps its own objects-only check: it is the agent loop, and moving it would change which tool results it awaits.
  6. Docs: reference/test.mdx and the TestAPI JSDoc say "truthy" for all four calls, name the one-argument difference from Playwright, and list the Promise case under INVALID_ARGUMENT. The translated reference/test.mdx pages carry the same JSDoc in their Types blocks. The Playwright migration guide names the one-argument difference: write test.skip(!!process.env.CI).

Issue

Fixes #1966

Overlap with open PRs

For the maintainer

  • A lone test.skip(undefined) or test.skip('') still skips, because it matches e2e's skip(reason?: string) overload. Playwright does nothing on either. So test.skip(process.env.CI) skips on every machine. Matching Playwright means narrowing the overload to skip(): void; skip(reason: string): void, which breaks callers that pass string | undefined. I kept today's behavior and documented the difference. A follow-up PR fits that change better.
  • Patch or breaking: a JavaScript suite with test.skip(asyncCheck(), 'x') is green today, always skipped, and fails with INVALID_ARGUMENT after this change. The changeset says patch.
  • isPromiseLike now also counts a function with a then method. That reaches test.skipIf, test.runIf, and describe: test.runIf(Object.assign(() => true, { then() {} })) registered a test before and is a COLLECTION_ERROR now.
  • test.skipIf(() => false) still skips at collection, and test.runIf(() => false) still runs, where the running forms now refuse a function. Whether skipIf and runIf should refuse one too is open.
  • Widening the condition type to SynchronousCondition<Condition>, as skipIf has, would let test.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

  • testbed, built CLI (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 at b3434936c. At the head, cc0bd6ad9 (that branch merged with main 7c1b2b258), I ran 15 of the table's calls again, with at least one row each for skip, fixme, fail, slow, and the beforeAll hook. Each result matched its row:
Call in the test body origin/main this branch
test.fixme(process.env.UNSET, 'only on CI') skipped [fixme: only on CI] passed
test.fixme(0, 'no items') skipped [fixme: no items] passed
test.fixme('yes', 'the real reason') skipped [fixme: yes] skipped [fixme: the real reason]
test.fixme(Promise.resolve(false), 'async check') skipped [fixme: async check] failed, test.fixme() got a Promise as its condition; await it before the call
test.fixme(true, 'crashes on webkit'), test.fixme() skipped skipped
test.slow(process.env.UNSET, 'only on CI'), 1500 ms body passed (timeout tripled) timed out after 1000 ms
test.slow(null), 1500 ms body passed (timeout tripled) timed out after 1000 ms
test.slow(true, 'large import'), test.slow(), 1500 ms body passed passed
test.slow(Promise.resolve(false), 'async check') passed failed, test.slow() got a Promise as its condition; await it before the call
test.slow(Promise.resolve(true)) in beforeAll hook passed HOOK_FAILED: beforeAll failed: test.slow() got a Promise as its condition; await it before the call
test.skip(Promise.resolve(false), 'x') and test.fail(...) in beforeAll HOOK_FAILED: ... must be called inside a test body (read from main's code) the same
test.skip(process.env.UNSET, 'only on CI'), test.fail(process.env.UNSET, 'gap') with a passing body skipped, or failed UNEXPECTED_PASS (from the maintainer's review) passed
test.skip(() => false, 'fn') skipped (from the maintainer's review) failed, test.skip() got a function as its condition; call it and pass the result
test.skip(0) alone skipped passed
test.skip('1', 'flaky') skipped [1] skipped [flaky]
  • The other main rows come from an origin/main (aaf923188) build running the same calls. On main, skipRunningTest and markRunningTestExpectedToFail check the location before the condition, so a beforeAll call fails there whatever the condition is.
  • Mutants, each run against the tests:
    • Reading a non-boolean condition as condition !== false fails modifier-call.test.ts.
    • Reading the condition before the location check fails the new beforeAll test for skip, and the new outside-a-test test.slow(Promise) case for slow.
    • Reading it after the setup-test check in skipRunningTest, or after the serial-member check in markRunningTestExpectedToFail, fails the new setup and serial cases.
    • Keeping condition === false in test.fail or test.slow, or letting a function through in test.slow, fails expected-failure.test.ts or test-slow.test.ts.
    • An objects-only isPromiseLike fails registry.test.ts. Dropping the lazy-schema branch fails mcp-tools.test.ts. Never adopting an async onSummary fails reporter-stress.test.ts.
  • At the head cc0bd6ad9, pnpm check passed, and so did the PR's test files: modifier-call, promise-like, registry, expected-failure (unit and integration), test-slow, mcp-tools, runner-lifecycle, and reporter-stress (169 of 169). The full packages/e2e suite passed 6718 of 6719 at b3434936c, 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

  • Behavior Updates
    • Conditional skip, fixme, fail, and slow modifiers now act on truthy conditions; falsy conditions leave the test unchanged.
    • Promise or function conditions are rejected with INVALID_ARGUMENT. Resolve promises or call functions before passing their results as conditions.
    • Unconditional modifier calls can use a string as the reason, except slow, which does not report a reason.
  • Documentation
    • Updated reference and migration guidance to describe condition handling and clarify that fail cannot be applied to setup tests or serial-group members.

@github-actions github-actions Bot added size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile needs:compliance Community PR fails CONTRIBUTING.md#pull-requests, closed after 72h if not fixed labels Nov 19, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

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

Comment thread docs/reference/test.mdx Resolved
Comment thread .changeset/modifier-falsy-condition.md Resolved
@github-actions github-actions Bot removed the needs:compliance Community PR fails CONTRIBUTING.md#pull-requests, closed after 72h if not fixed label Nov 19, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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

@samanyudas
samanyudas marked this pull request as draft November 19, 2026 10:55
@samanyudas

Copy link
Copy Markdown
Contributor Author

Note

🤖 Drafted by GPT-6.2 Sol. Reviewed by samanyudas and posted on their behalf.

I’ve moved this PR back to draft to avoid overlapping changes. I’ll pick it back up once #1887, #1914, #1925, and #1858 land on main.

@samanyudas

Copy link
Copy Markdown
Contributor Author

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 main):

  • #1914 test.skip() from teardown: 57 commits behind main, 28 checks passed.
  • #1858 test.todo: 38 commits behind main, 4 checks passed and 5 pending.

This PR stays in draft until those two land. It is also conflicting and 81 commits behind main.

Since #1887 has landed, test.fixme still calls parseModifierCall with the old (first, second) signature. I need to move it to fixme(...args) with parseModifierCall('test.fixme()', args) here and add the test.fixme(undefined, 'x') and Promise cases.

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.fixme and test.slow to the new parseModifierCall(api, args) shape. On main, test.skip, test.fixme, test.fail and test.slow all call the old parser, which still reads any condition that is not a boolean as true (skip.ts:81 on main; callers at registry.ts:928 for fixme and registry.ts:947 for slow). So after a rebase that only resolves the conflicts, test.fixme(undefined, 'r') still skips and test.slow(undefined) still triples the timeout. Your comment of 2026-11-22 already plans the fixme move, which the triage on #1966 asked for. test.slow (#1982) landed after that comment and needs the same move: Playwright 1.65.1 reads slow the same way as the others, and a falsy condition does nothing. git merge-tree against main conflicts in skip.ts, registry.ts, docs/reference/test.mdx, docs/core-concepts.mdx and docs/migrate/playwright.mdx.

    Can the rebase add a test.fixme(undefined, 'r') case that runs the test, and a test.slow(undefined) case that keeps the normal timeout, beside the existing skip and fail ones? Please also extend the changeset to name fixme and slow, and add the two other changes users will see: test.skip('1', 'flaky') now reports the reason flaky (main reports 1), and a lone test.skip(0) or test.skip(null) no longer skips.

Optional

  • modifier-call.test.ts:49: the truthiness table runs with no test attempt, so parseModifierCall returns at skip.ts:57 and never reaches skip.ts:63, the line a real test body takes. I changed line 63 so 0, null, '' and NaN skip again, and all 110 tests in the PR's five test files still passed. Running the two-argument loop inside the file's inBody helper catches it: with that change it fails on condition: 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 from report.json. "Main's code" is this commit with internal/skip.ts, collect/registry.ts and mcp/tools.ts put back to 19d25806c and 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 body failed UNEXPECTED_PASS passed
    test.fail(0, 'gap'), throwing body passed as an expected failure failed with the real error
    test.skip(Promise.resolve(false), 'x'), a thenable object, test.fail with a Promise skipped, or UNEXPECTED_PASS failed INVALID_ARGUMENT
    test.skip(() => false, 'fn') skipped failed INVALID_ARGUMENT
    test.skip(true, 'on'), test.skip(false, 'off'), test.fail(true, 'gap') with a throwing body unchanged unchanged
    test.skip(), test.skip('waiting'), test.skip(undefined), test.skip(''), test.skip(1) skipped skipped
    test.skip(0) alone skipped passed
  • The PR's five test files at this commit: 110 of 110 pass (pnpm install, pnpm run build, then vitest on modifier-call, promise-like, registry, expected-failure and runner-lifecycle).

  • Mutants: nine of ten on the new code in parseModifierCall, readCondition and isPromiseLike fail one of the PR's tests on an assertion; the tenth survives, which is the optional finding above, and the inBody test 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, fail and slow, 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 full pnpm 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 undefined or '' still always skips, where Playwright does nothing. TypeScript allows it with no cast, so test.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 with INVALID_ARGUMENT after this change. The changeset says patch.
  • Not asked for in the issue: isPromiseLike now also counts a function with a then method, which reaches test.skipIf, test.runIf and describe. test.runIf(Object.assign(() => true, { then() {} })) registered a test before and is a COLLECTION_ERROR now.
  • 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.

@samanyudas
samanyudas force-pushed the fix/modifier-falsy-condition branch from 189dca9 to b343493 Compare November 28, 2026 05:35
@samanyudas samanyudas changed the title fix(test): read the test.skip and test.fail condition by truthiness fix(test): read the test.skip, test.fixme, test.fail, and test.slow condition by truthiness Nov 28, 2026
@samanyudas
samanyudas marked this pull request as ready for review November 28, 2026 05:36
…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>
@samanyudas
samanyudas force-pushed the fix/modifier-falsy-condition branch from b343493 to 0d6c7d0 Compare November 28, 2026 05:37
@samanyudas

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of samanyudas

Rebased onto main (aaf923188) as one commit, 0d6c7d093. Every ask from the review is in it:

  1. Done: test.fixme and test.slow now go through the same parser as test.skip and test.fail. Each of the four APIs reads the condition itself, after its own location check (readRunningCondition in packages/core/src/internal/condition.ts). So a falsy condition does nothing in a test body or a hook. A misplaced call keeps main's error, for example test.skip(promise, 'x') in a beforeAll.
  2. Done: test.fixme(undefined, 'only on CI') runs the test (runner-lifecycle.test.ts). test.slow(undefined, 'only on CI') keeps the normal timeout (test-slow.test.ts). The Promise and function cases are there too. I used the two-argument form for slow on purpose. A lone test.slow(undefined) matches the slow(reason?: string) overload, so it still triples the timeout, the same way a lone test.skip(undefined) still skips. Matching Playwright there is the overload change you suggested as a follow-up, and that follow-up would change all four APIs together.
  3. Done: the changeset names all four APIs. It says a falsy condition does nothing and the reason comes from the second argument, which covers test.skip('1', 'flaky') reporting flaky. It also says a lone test.skip(0) or test.skip(null) no longer skips. It now also lists @e2e-dev/core, because the fail and slow changes live there.
  4. Done (optional item): modifier-call.test.ts now tests the truthiness table on readRunningCondition, the reader every API uses in running code. Your mutant, condition !== false in its place, fails that test. So does reading the condition before the location check, for skip, fail, and slow.

The PR body describes the new head, with a main against branch table for fixme, slow, and the beforeAll cases. On #1914: this PR no longer waits for it. The two conflict only in text, in internal/skip.ts and reference/test.mdx, so whichever lands second resolves them.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

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

Comment thread docs/pt/reference/test.mdx Resolved
Comment thread docs/pt/reference/test.mdx Resolved
Comment thread docs/ja/reference/test.mdx Resolved
Comment thread packages/core/src/internal/condition.ts Resolved
Comment thread docs/reference/test.mdx Resolved
…ws to hooks and fixtures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

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

Comment thread .changeset/modifier-falsy-condition.md Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

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 okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 fixme and slow to the new parser, add tests, extend the changeset): fixed. All four call parseModifierCall(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 cover test.fixme(undefined, 'only on CI') (runner-lifecycle.test.ts:305) and test.slow(undefined, 'only on CI'). The changeset names all four APIs, the reason change, and the lone test.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 lone undefined matches the slow(reason?) overload and still triples the timeout. That matches skip, and the PR documents it. See the first maintainer item.
  • Optional inBody table: no longer needed. readRunningCondition is 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 on modifier-call, promise-like, registry, expected-failure, runner-lifecycle and test-slow: 130 of 130 pass.
  • Mutants, each with core or e2e rebuilt. All 8 fail at least one test:
    • M1: condition === false at the skipRunningTest call site
    • M2: the same in test.fail
    • M3: the same in test.slow
    • M4: the args.length <= 1 guard 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
  • Playwright 1.65.1 TestInfo._modifier (from the npm package) returns early on modifierArgs.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 with INVALID_ARGUMENT, which the triage on #1966 agreed to, and a lone undefined or '', which the PR documents.
  • isPromiseLike now has one shared definition. It behaves the same as the replaced code-recorder.ts isThenable and the inline checks in reporter-host.ts and tools.ts.

For the maintainer

  • A lone test.skip(undefined) or test.skip('') still skips (also fixme, fail, slow), where Playwright does nothing. So test.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?
  • patch vs breaking: a JS suite with test.skip(asyncCheck(), 'x') is always skipped today and fails with INVALID_ARGUMENT after this change.
  • test.skipIf and test.runIf still accept a function, which is always truthy, while the running forms now refuse one. Should they refuse it too?
  • packages/core/src/types.ts is on the public contract list. Only the JSDoc changes there; the signatures stay the same.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 28, 2026
@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 28, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Test modifier condition handling

Layer / File(s) Summary
Shared condition validation
packages/core/src/internal/condition.ts, packages/core/src/internal/promise-like.ts, packages/core/src/internal/expected-failure.ts, packages/core/src/internal/test-timeout.ts, packages/e2e/tests/unit/modifier-call.test.ts, packages/e2e/tests/unit/promise-like.test.ts
Core helpers convert conditions by truthiness and reject Promise-like or function values for running-test modifiers. test.fail and test.slow use the shared validation.
Modifier parsing and wiring
packages/e2e/src/collect/registry.ts, packages/e2e/src/internal/skip.ts, packages/e2e/tests/unit/modifier-call.test.ts, packages/e2e/tests/unit/registry.test.ts
Modifier methods pass argument arrays to parseModifierCall. Runtime skip handling validates conditions, and collection-time condition checks use shared helpers.
Modifier behavior coverage and documentation
packages/e2e/tests/integration/expected-failure.test.ts, packages/e2e/tests/integration/runner-lifecycle.test.ts, packages/e2e/tests/integration/test-slow.test.ts, packages/e2e/tests/types/sdk-types.ts, packages/core/src/types.ts, docs/*/reference/test.mdx, docs/reference/test.mdx, docs/migrate/playwright.mdx, .changeset/modifier-falsy-condition.md
Integration and type tests cover modifier conditions. Reference documentation and the changeset describe the updated behavior.
Shared Promise-like detection
packages/e2e/src/run/reporter-host.ts, packages/e2e/src/session-tools/code-recorder.ts, packages/e2e/src/session-tools/tools.ts, packages/e2e/tests/integration/reporter-stress.test.ts, packages/e2e/tests/unit/mcp-tools.test.ts
Reporter handling, recorder methods, and tool schema rendering use the shared Promise-like utility. Tests cover rejected reporter summaries and asynchronous schema results.

Suggested reviewers: okwasniewski, przytrzask, michal-e2e

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to cc0bd

Test modifier conditions now use truthiness, and Promise or function conditions fail with a clear INVALID_ARGUMENT error. No merge-blocking risk was found. JavaScript callers who passed async conditions will now see errors, which is the stated intent.

Security architecture risk: Minimal · up to cc0bd

The modifier changes can affect which tests run, which failures are expected, and how long tests run. They preserve the existing limits on who can change those outcomes. The reviewed change does not establish a new security exposure or weaken failure containment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — Reporter summary adoption and tool schema fallback already recognized callable thenables at the merge base. The shared check does not newly route a reporter result or tool schema into those branches.

Trust Boundaries and Controls

  • observed — Expected-failure marking still requires an eligible active attempt. The runner keeps the first mark, and verdict settlement excludes INVALID_ARGUMENT from the failures that an existing mark can turn into a pass.

Resilience and Maintainability Implications

  • observed — Recorder.given and Recorder.call classify the same values as thenable at base and head. The substitution leaves invocation, recording and settlement ordering, and interleaving bookkeeping unchanged.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 72285472-dbf3-4a49-a23c-cffb3a997c59
Commits

Reviewing files that changed from the base of the PR and between 7c1b2b2 and cc0bd6a.

Files selected for processing: 26

  • .changeset/modifier-falsy-condition.md
  • docs/hi/reference/test.mdx
  • docs/ja/reference/test.mdx
  • docs/migrate/playwright.mdx
  • docs/pt/reference/test.mdx
  • docs/reference/test.mdx
  • docs/zh/reference/test.mdx
  • packages/core/src/internal/condition.ts
  • packages/core/src/internal/expected-failure.ts
  • packages/core/src/internal/promise-like.ts
  • packages/core/src/internal/test-timeout.ts
  • packages/core/src/types.ts
  • packages/e2e/src/collect/registry.ts
  • packages/e2e/src/internal/skip.ts
  • packages/e2e/src/run/reporter-host.ts
  • packages/e2e/src/session-tools/code-recorder.ts
  • packages/e2e/src/session-tools/tools.ts
  • packages/e2e/tests/integration/expected-failure.test.ts
  • packages/e2e/tests/integration/reporter-stress.test.ts
  • packages/e2e/tests/integration/runner-lifecycle.test.ts
  • packages/e2e/tests/integration/test-slow.test.ts
  • packages/e2e/tests/types/sdk-types.ts
  • packages/e2e/tests/unit/mcp-tools.test.ts
  • packages/e2e/tests/unit/modifier-call.test.ts
  • packages/e2e/tests/unit/promise-like.test.ts
  • packages/e2e/tests/unit/registry.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@samanyudas

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of samanyudas

I merged main (7c1b2b258) into the branch in cc0bd6ad9, so the PR no longer conflicts. The review found nothing for the author to change, and this push changes no source code.

Git flagged two conflicts in the docs. I resolved them this way:

  • docs/core-concepts.mdx: I kept main's shorter "Organize tests" section. Main removed the "Skip conditionally" bullet, so this PR's "truthy" wording for it is dropped too.
  • docs/reference/test.mdx: I kept main's Types block without the JSDoc, and this PR's test.slow bullet ("The condition reads as in test.skip...") in place of main's "With a false condition it does nothing".

I checked the merge with these runs at cc0bd6ad9:

  • pnpm check passes.
  • The PR's test files pass, 169 of 169.
  • I ran 15 of the PR body's calls through the built CLI on the testbed, and each result matched its row. Some examples:
    • test.skip(undefined, 'only on CI'), test.fixme(undefined, ...), and test.fail(undefined, ...) with a passing body all pass.
    • test.slow(undefined, ...) times out after 1000 ms.
    • test.skip('1', 'flaky') is skipped [flaky].
    • A Promise or a function as the condition fails the test with INVALID_ARGUMENT.
    • test.skip(promise) in a beforeAll keeps main's HOOK_FAILED location error.

The four "For the maintainer" questions are still open in the PR body. They are the lone test.skip(undefined) overload, patch or breaking, skipIf and runIf with a function, and the JSDoc-only change in types.ts.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 28, 2026

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.slow description. 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.

@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 30, 2026

This branch has not been deployed

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

Labels

size:L Up to 499 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test.skip and test.fail treat a falsy non-boolean condition as true inside a test body

3 participants