Repository navigation
feat(test): add test.each and test.for - #1882
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 10 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 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
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Reviewed b8fd388 (main b369e38), compared with Vitest 5.1.0's formatTitle / taskFn.each / taskFn.for by running the same rows through both. Call shapes work with options, serial groups and test.extend, and the unit tests kill every mutant I tried.
Must fix
packages/e2e/src/collect/each.tsdisplay()and%o:inspect(value, { breakLength: Infinity, depth: 4 })still breaks lines, because Node's defaultcompact: 3groups arrays over 6 items and splits objects nested 4+ deep.test.each([[[1,2,3,4,5,6,7]]])('ids %s', ...)registers"ids [\n 1, 2, 3, 4,\n 5, 6, 7\n]"and the test id becomestests/p.e2e.ts::ids%20%5B%0A...(confirmed on the fake engine).$tagswith 7+ items hits the same. Titles are test ids, so they must be one line. Fix: addcompact: true(keeps a 30-item array and a 5-deep object on one line) and a title test row for it.
Should fix
registry.tseachRegistrardecides per row whether to spread. Vitest (cases.every(Array.isArray)) and Jest decide once for the table, so intest.each([[1, 'one'], { user: 'Ada' }])Vitest passes every row whole, while here fixtures land at a different position per row. Spread only when every row is an array and makeEachArgsnon-distributive ([Row] extends [readonly unknown[]]). The unit test "passes test.each rows spread..." locks in the current behavior.each.tsjson(): the catch turns every error into[Circular], so a BigInt row is titled[Circular]and two of them fail with a duplicate-title error about a value they never had. Rethrow non-circular errors as aCOLLECTION_ERRORnaming the row, as Vitest does.- The docs say "as in Vitest". Either close these or say they differ:
$0/$1on array rows,$keyread from an array row whose first item is an object,%susing a customtoString(URLprints its href, here it dumps the inspected object),%O,%c.
Nits
eachRegistrarrepeatsregistrar(requireCollector,modeOf,registerTest). Registering each row throughregistrar(api)(rowTitle, options, rowFn)removes the copy.- Docs: a
%#title changes id when rows move; one line recommending$namefor stable ids helps. %fon-0prints0, Vitest prints-0.
Verified: registry.test.ts 47/47, the new runner-lifecycle case, tsc --noEmit incl. sdk-types.ts (ragged rows, as const tuples infer right), lint, CI green. Mutants killed: no spread, empty chain, mode ignoring options, %# off by one, leftover placeholders, $name on non-object rows, empty rows accepted, %% dropped.
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Heads-up: the Japanese docs (#1875) landed on main after this branched. |
b8fd388 to
bb7e133
Compare
|
Thanks for the careful review. Rebased on main (with the ja and zh docs) and pushed bb7e133. Must fix
Should fix
Nits
The ja and zh pages mirror the new Checked: |
There was a problem hiding this comment.
All reported issues were addressed across 8 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
There was a problem hiding this comment.
All reported issues were addressed across 7 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
There was a problem hiding this comment.
0 issues found 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
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked 89622e9 (main fabb0c0) against the earlier review, compared with Vitest 5.1.0's formatTitle / format / taskFn.each / taskFn.for from node_modules (the version this repo installs).
Earlier asks, all done:
- One-line titles:
inspectusescompact: true; 7-item arrays,$tagsand 5-deep%ostay on one line (test rows added). - Spread decided once per table (
every(Array.isArray), as Vitest),EachArgsnon-distributive,unknownrows typed[...unknown[], Fixtures]. %j: only Node's circular TypeError becomes[Circular], other failures throwCOLLECTION_ERRORnaming the row.eachRegistrargoes throughregistrar(api);%fon-0; stable-id note; Vitest differences listed in the docs.- ja + zh mirrors cover the new sections, member rows and type blocks;
docs:checkpasses (162 pages match). Every cubic thread is fixed at this head.
Should fix
packages/e2e/src/collect/each.tsjson():JSON.stringify(value) ?? String(value)puts a function's full source in the title when%jgets a function, sotest.each([[function named(a) {\n return a;\n}]])('%j', ...)registers a multi-line title (and test id). That's the same one-line problem the earlier must-fix was about. Vitest printsundefinedhere (and for a Symbol). Fix:?? 'undefined', plus a title row.
Nits
registry.tsmodeOf()now has one caller (registrar), sinceeachRegistrargoes throughregistrar. Inline it back so the diff stays small..changeset/test-each-for.mdstill says the title formats "as in Vitest", which the docs now walk back. Drop that phrase.TOKENonly matches ASCII keys, so$名前stays as written. Vitest matches\p{ID_Continue}. Use[\p{ID_Start}_$][\p{ID_Continue}$]*with theuflag, or list it with the other differences.- Docs list title differences but not that Vitest's
test.eachbody gets no test context, while here the fixtures come last. One clause in the differences bullet covers it.
Verified: CI green at 89622e9 (all checks). Locally: registry.test.ts 47/47, oxlint clean, docs:check clean, tsc clean apart from errors in packages I didn't build (@e2e-dev/web, e2e/engine). Mutants killed: every -> some on the spread rule, compact: true removed, any TypeError treated as circular, [Circular] path removed, -0 special case removed. Probed %j on a function and a Symbol, $名前, $user., a custom toString and %i%% %s directly through formatEachTitle. The $user., custom toString and %i%% %s cases are fine: the first and last are better than Vitest, and the toString one is already documented.
Waiting on a maintainer decision: truncate long values in titles like Vitest (40 chars) or not; settle before merge since it changes test ids. Labeling for human review.
Earlier asks done, see latest automated review.
|
Thanks, all five done in 2c5541a:
On truncating long values in titles: happy to add Vitest's 40-char cut if you want it. I left titles whole for now since it changes test ids. |
There was a problem hiding this comment.
0 issues found across 7 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
|
The |
2c5541a to
53218f2
Compare
|
Looked closer at the So the deep-link confirm prompt from |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked 53218f2 (main 66d07ca). The branch was rebased: git range-diff shows all six commits identical to the old ones, and 53218f2 is 2c5541a rebased onto current main.
Earlier asks, all done:
%jprintsundefinedfor a function, aSymbolandundefined, so a function's source can't land in a title. Same as Vitest 5.1.0.$nameand its path segments use\p{ID_Start}/\p{ID_Continue}withu, the same character class as Vitest'sformatAttribute.$名前and$ユーザー.名read the row.- The mode is inlined back into
registrar, so it matches main andregistry.tsonly gains the each/for code. - The changeset no longer says "as in Vitest". The differences bullet now covers the body shape (fixtures come after the row), mirrored in ja and zh.
Must fix: none.
Should fix: none.
CI: everything is green except ios deterministic (and the mobile gate that depends on it). That failure is not caused by this PR. In the first pass, on simulator 15C2, iOS's "Open in "e2e Benchmark"?" prompt from device-fixture.e2e.ts > openLink never got dismissed. Every later test on that simulator then failed in openScenario with the prompt still on screen (see screen-at-failure.txt in the artifact). In the --last-failed rerun, the device-fixture tests passed on the other simulator (5D7D), and the flows-lists tests failed again on 15C2, which was still blocked. No mobile-benchmark test uses test.each / test.for, and the diff only touches title formatting, the each/for registrars, types and docs. I re-ran the failed jobs.
Verified:
registry.test.tspasses 47/47.- oxlint is clean,
docs:checkpasses (162 translated pages match), andtscis clean apart from imports of packages I didn't build (@e2e-dev/web,e2e/engine). - The skill copies are in sync.
- Killed three mutants:
?? 'undefined'back to?? String(value), the first$keysegment back to ASCII, and the path segments back to\w.
Still waiting on the maintainer decision from the last pass: whether to truncate long values in titles like Vitest does (40 chars). It changes test ids, so settle it before merge.
…s [Circular] An unknown row may be spread or passed whole at run time, so EachArgs now types only the fixtures, last. %j only reads Node's circular-structure TypeError as a cycle; a toJSON that throws names the row. Docs say %d keeps BigInt's n suffix and shows Symbol as NaN, and that a string title value keeps its line breaks.
…de $keys - %j prints undefined for what JSON leaves out, as Vitest does, so a function's source never lands in a title - $name and its path read Unicode identifier characters - inline the test mode back into registrar - docs: note that a Vitest test.each body gets no fixtures
Fixtures are now set up on demand from what the body destructures (#1891). A test.each row runs a wrapper, (fixtures) => body(...row, fixtures), so registration read the wrapper's own parameter and refused every row with "must destructure its first parameter". registerTest now takes the body and the position of its fixtures parameter (the row's length when it is spread, else 1), and fixtureNames reads that parameter.
53218f2 to
54d5ea0
Compare
|
Rebased on main (54d5ea0) after #1891. #1891 sets fixtures up from what a function destructures, and a An unknown-row Checked: |
- An Error in a title shows as its name and message, not its stack, and whatever inspect still breaks is joined, so a title is always one line - The source location reads the whole stack: the default 10 frames cut the test file off a row declared through a helper and a describe - A tagged template table is a COLLECTION_ERROR instead of one test per template chunk - A bound row body is told how to wrap itself with the row first - tests: a run sets up only the fixtures a row body names; fixtureNames at a position - docs, skill, changeset: a row body names its fixtures after the row
|
[claude-fable-5-2] automated review on behalf of @okwasniewski Re-checked 54d5ea0 (main 847a09e). The rebase and the fixture fix are right: the fixtures parameter is the row's length when the row is spread, else 1, and a body that takes them whole or in a rest parameter is refused. CI is green. On the built CLI against the testbed, object rows and spread rows fill the todos page under a A fresh review found four more things. I fixed them, but I can't push here: the fork is org-owned, so GitHub refuses maintainer pushes. They are one commit on top of your head, git pull --ff-only https://github.com/e2e-inc/e2e.git oskar/test-each-review-fixes
git pushMust fix (each has a test that fails without the fix)
Should fix
Not changed: a regex literal default before the fixtures parameter ( Verified on |
|
Thanks for the fixes. I pulled |
There was a problem hiding this comment.
All reported issues were addressed across 13 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
- stackLocations puts Error.stackTraceLimit back in a finally - Only an own raw property marks a template table - The wrap hint for a bound row body names one argument per row item - skill: rows are spread only when every row is an array
|
[claude-fable-5-2] responding on behalf of @okwasniewski Thanks for pulling it. The review bot found four small things in my commit, all valid. They are fixed in git pull --ff-only https://github.com/e2e-inc/e2e.git oskar/test-each-review-fixes
git push
Each code change has a test that failed before it. |
|
The four cubic points on
|
b6856a9 to
5d08151
Compare
|
Our fixes crossed: I pushed |
Resolve e2e-inc#1882's split of registrar into registerOne: registerOne takes skip as boolean | 'fixme' | undefined and owns the fixme options and mode, and registrar passes skip through. Keep both sides of the sdk-types and runner-lifecycle cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds
test.each(rows)andtest.for(rows), the Vitest shape: one test per row, titled from the row.$name/$name.pathread an object row;%s %d %i %f %j %otake an array row's items in order;%#is the index,%$the row number,%%a percent sign. Formatting is one pass, so a value is never read as a token (packages/e2e/src/collect/each.ts). A title is always one line: anErrorshows as its name and message, not its stack.test.eachspreads the rows into the body's args when every row is an array (decided once per table, as Vitest does);test.forpasses the row whole. The fixtures come last in both.fixtureNames(fn, what, source, position)inpackages/e2e/src/collect/fixture-names.ts).(row, fixtures) => {}and(...args) => {}are aCOLLECTION_ERROR, as(fixtures) => {}is for a plain test.test()(packages/e2e/src/collect/registry.ts), so options (skip, tags, timeout), serial groups, and duplicate-title checks work as for a plain test. Every row is located at itstest.eachcall, through a helper too: the source location now reads the whole stack, not the default 10 frames.COLLECTION_ERROR.TestAPI.each/TestAPI.forinpackages/core/src/types.ts; pinned intests/types/sdk-types.ts, incl. tuple rows typed per position.Out of scope:
describe.each, and.eachchained afterskip/only/skipIf.Issue
Part of #1855 (Test runner row).
Verified
Ran it locally: yes
tests/zz-each.e2e.ts: object rows and spread rows that fill the real todos page under abeforeEach,test.for, rows that name no fixture, anErrorrow, and skipped rows.e2e listshows one entry per row with the formatted title.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.