Skip to content

Add .each to Fantom's describe, it and test - #60586

Open
YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/fantom-test-each
Open

YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/fantom-test-each

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor

Summary:

Fantom's runtime defines describe, it and test without their .each forms, while flow-typed/environment/jest.js, which Fantom tests are checked against, declares each on all three. A table test therefore passes Flow and then fails its whole suite when Fantom runs it:

[…]
FAIL fantom private/react-native-fantom/src/__tests__/setup/each-itest.js
  ● Test suite failed to run

    TypeError: undefined is not a function
[…]

This adds runtime/each.js, which gives describe, it, test and their only and skip forms an each (so fdescribe, xdescribe, fit, xit and xtest have one too), following jest-each:

  • an array of arrays spreads each row into the test, and a flat array passes each value alone; titles take %p, %s, %d, %i, %f, %j, %o, %O, %#, %$ and %%;
  • an array of objects passes each object, and titles take $key, $key.path and $#;
  • a tagged template table passes one object per row of its headings;
  • a table it cannot read declares one failing test under the title, with the message jest-each gives an empty or incomplete table and the test file as its first frame; for describe.each that fails the file, as a throwing describe does.

jest-each formats titles with Node's util.format and util.inspect, which a Hermes bundle cannot load, so a value under %o or %O, and an object under %s whose toString is a built-in one, print with pretty-format, as %p prints them; a %c or a second %# stays in the title as written, and the messages carry no colours. A placeholder inside a printed value also stays as written, where jest-each fills it with the next value (jestjs/jest#16559 proposes the same for jest-each); a template whose headings are not a string fails with Table headings do not conform to expected format; and a function as the title fails the table, since Fantom's describe and it take a string.

The libdef gives describe.only, describe.skip and fit an each, as Jest's own types do.

Fixes #60563.

Changelog:

[INTERNAL] [ADDED] - Fantom: describe.each, it.each and test.each, with their only and skip forms

Test Plan:

I ran these CI jobs with their workflows' steps in a Linux container on Node 22.14.0 (test-all.yml runs test_js on Node 24 and 22.13.0):

  • lint (ESLint, Flow, the legacy TypeScript check) and test_js pass; Jest gives Test Suites: 303 passed, 303 total, Tests: 1 skipped, 6968 passed, 6969 total, the .each cases being in private/react-native-fantom/runtime/__tests__/setup-test.js.
  • run_fantom_tests (yarn fantom --ci): Test Suites: 26 skipped, 209 passed, 209 of 235 total, Tests: 73 skipped, 4330 passed, 4403 total. The new private/react-native-fantom/src/__tests__/setup/each-itest.js is among them, checking on Hermes the rows, an object's toString under %s and the first frame of a table it cannot read; its test.each, it.each and describe.each tables, run on main, fail the suite with TypeError: undefined is not a function.
  • build_js_types passes, and so does format.yml's check for every formatter but swift, which needs a Swift 6.3 toolchain the container lacks.

I did not run test_android, test_ios or test_react_common_cxx, which test-all.yml starts for this change.

Fantom's runtime installed `describe`, `it` and `test` without the `.each` forms that the Flow Jest libdef declares, so a table test passed Flow and threw when it ran. Each declaration and its `only` and `skip` forms now get an `each` in jest-each's forms: array tables with printf placeholders, object tables with `$key` titles, and tagged template tables; an `it.each` or `test.each` table it cannot read declares one failing test that says why, and a `describe.each` one fails the file. The libdef gives `describe.only`, `describe.skip` and `fit` an `each`, as Jest's own types do.

Signed-off-by: YevheniiKotyrlo <44449990+YevheniiKotyrlo@users.noreply.github.com>
@YevheniiKotyrlo
YevheniiKotyrlo marked this pull request as ready for review December 5, 2026 02:09

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fantom: test.each and describe.each are undefined at run time, though the Jest types Fantom tests are checked against declare them

1 participant