You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@
19
19
-`[jest-core]` Add support for `globalSetup` and `globalTeardown` written in ESM ([#11267](https://github.com/facebook/jest/pull/11267))
20
20
-`[jest-core]` Add support for `watchPlugins` written in ESM ([#11315](https://github.com/facebook/jest/pull/11315))
21
21
-`[jest-core]` Add support for `runner` written in ESM ([#11232](https://github.com/facebook/jest/pull/11232))
22
+
-`[jest-each]` Add support for interpolation with object properties ([#11388](https://github.com/facebook/jest/pull/11388))
22
23
-`[jest-environment-node]` Add AbortController to globals ([#11182](https://github.com/facebook/jest/pull/11182))
23
24
-`[@jest/fake-timers]` Update to `@sinonjs/fake-timers` to v7 ([#11198](https://github.com/facebook/jest/pull/11198))
Copy file name to clipboardExpand all lines: docs/GlobalAPI.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,6 +245,10 @@ Use `describe.each` if you keep duplicating the same test suites with different
245
245
-`%o` - Object.
246
246
-`%#` - Index of the test case.
247
247
-`%%` - single percent sign ('%'). This does not consume an argument.
248
+
- Or generate unique test titles by injecting properties of test case object with `$variable`
249
+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value`
250
+
- You can use `$#` to inject the index of the test case
251
+
- You cannot use `$variable` with the `printf` formatting except for `%%`
248
252
-`fn`: `Function` the suite of tests to be ran, this is the function that will receive the parameters in each row as function arguments.
249
253
- Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait for each row before aborting. _Note: The default timeout is 5 seconds._
250
254
@@ -270,6 +274,26 @@ describe.each([
270
274
});
271
275
```
272
276
277
+
```js
278
+
describe.each([
279
+
{a:1, b:1, expected:2},
280
+
{a:1, b:2, expected:3},
281
+
{a:2, b:1, expected:3},
282
+
])('.add($a, $b)', ({a, b, expected}) => {
283
+
test(`returns ${expected}`, () => {
284
+
expect(a + b).toBe(expected);
285
+
});
286
+
287
+
test(`returned value not be greater than ${expected}`, () => {
288
+
expect(a + b).not.toBeGreaterThan(expected);
289
+
});
290
+
291
+
test(`returned value not be less than ${expected}`, () => {
@@ -655,6 +679,10 @@ Use `test.each` if you keep duplicating the same test with different data. `test
655
679
-`%o` - Object.
656
680
-`%#` - Index of the test case.
657
681
-`%%` - single percent sign ('%'). This does not consume an argument.
682
+
- Or generate unique test titles by injecting properties of test case object with `$variable`
683
+
- To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value`
684
+
- You can use `$#` to inject the index of the test case
685
+
- You cannot use `$variable` with the `printf` formatting except for `%%`
658
686
-`fn`: `Function` the test to be ran, this is the function that will receive the parameters in each row as function arguments.
659
687
- Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait for each row before aborting. _Note: The default timeout is 5 seconds._
0 commit comments