Skip to content

Commit dc8d8a1

Browse files
Add .each to Fantom's describe, it and test
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.
1 parent e812580 commit dc8d8a1

6 files changed

Lines changed: 820 additions & 11 deletions

File tree

‎flow-typed/environment/jest.js‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,33 @@ declare var describe: {
10351035
/**
10361036
* Only run this describe block
10371037
*/
1038-
only(name: JestTestName, fn: () => void): void,
1038+
only: {
1039+
(name: JestTestName, fn: () => void): void,
1040+
each(
1041+
...table:
1042+
| ReadonlyArray<ReadonlyArray<unknown> | unknown>
1043+
| [ReadonlyArray<string>, string]
1044+
): (
1045+
name: JestTestName,
1046+
fn?: (...args: ReadonlyArray<any>) => any,
1047+
timeout?: number,
1048+
) => void,
1049+
},
10391050
/**
10401051
* Skip running this describe block
10411052
*/
1042-
skip(name: JestTestName, fn: () => void): void,
1053+
skip: {
1054+
(name: JestTestName, fn: () => void): void,
1055+
each(
1056+
...table:
1057+
| ReadonlyArray<ReadonlyArray<unknown> | unknown>
1058+
| [ReadonlyArray<string>, string]
1059+
): (
1060+
name: JestTestName,
1061+
fn?: (...args: ReadonlyArray<any>) => any,
1062+
timeout?: number,
1063+
) => void,
1064+
},
10431065
/**
10441066
* each runs this test against array of argument arrays per each run
10451067
*
@@ -1136,11 +1158,7 @@ declare var it: {
11361158
...
11371159
};
11381160

1139-
declare function fit(
1140-
name: JestTestName,
1141-
fn: JestProvidesCallback,
1142-
timeout?: number,
1143-
): void;
1161+
declare var fit: typeof it.only;
11441162
/** An individual test unit */
11451163
declare var test: typeof it;
11461164
/** A disabled group of tests */

‎private/react-native-fantom/__docs__/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ file.
8181

8282
The high level structure of Fantom tests is similar to Jest unit tests. However,
8383
only a subset of Jest's Global API is currently available. For example,
84-
`test.each` is not yet implemented in Fantom. We are working on adding more Jest
84+
`test.todo` is not yet implemented in Fantom. We are working on adding more Jest
8585
APIs. If you are blocked by the lack of a specific API, please reach out to us.
8686

8787
Most of the interesting APIs are available via the `@react-native/fantom`
@@ -351,7 +351,7 @@ expect(root.getRenderedOutput().toJSX()).toEqual(
351351
### Limitations
352352

353353
- `Fantom.runTask()` calls cannot be nested — doing so will throw.
354-
- Only a subset of Jest's Global API is available (e.g. `test.each` is not
354+
- Only a subset of Jest's Global API is available (e.g. `test.todo` is not
355355
implemented). Reach out if you're blocked by a specific missing API.
356356
- Tests must live within `packages/react-native`; Fantom is not currently
357357
intended for application-specific code.

0 commit comments

Comments
 (0)