Skip to content

Commit b4af639

Browse files
authored
Merge branch 'main' into improve-each-template-literal-infer
2 parents bdf450c + 375b3ee commit b4af639

File tree

69 files changed

+4655
-3908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4655
-3908
lines changed

.yarn/releases/yarn-3.8.0.cjs renamed to .yarn/releases/yarn-3.8.1.cjs

Lines changed: 172 additions & 172 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ plugins:
3333
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
3434
spec: "@yarnpkg/plugin-workspace-tools"
3535

36-
yarnPath: .yarn/releases/yarn-3.8.0.cjs
36+
yarnPath: .yarn/releases/yarn-3.8.1.cjs

CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
- `[@jest/fake-timers]` Exposing new modern timers function `advanceTimersToFrame()` which advances all timers by the needed milliseconds to execute callbacks currently scheduled with `requestAnimationFrame` ([#14598](https://github.com/jestjs/jest/pull/14598))
2121
- `[jest-mock]` Add support for the Explicit Resource Management proposal to use the `using` keyword with `jest.spyOn(object, methodName)` ([#14895](https://github.com/jestjs/jest/pull/14895))
2222
- `[jest-runtime]` Exposing new modern timers function `jest.advanceTimersToFrame()` from `@jest/fake-timers` ([#14598](https://github.com/jestjs/jest/pull/14598))
23-
- `[jest-runtime]` Support `import.meta.filename` and `import.meta.dirname` (available from [Node 20.11](https://nodejs.org/en/blog/release/v20.11.0))
23+
- `[jest-runtime]` Support `import.meta.filename` and `import.meta.dirname` (available from [Node 20.11](https://nodejs.org/en/blog/release/v20.11.0)) ([#14854](https://github.com/jestjs/jest/pull/14854))
24+
- `[jest-runtime]` Support `import.meta.resolve` ([#14930](https://github.com/jestjs/jest/pull/14930))
2425
- `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.31 ([#14072](https://github.com/jestjs/jest/pull/14072))
2526
- `[@jest/types]` `test.each()`: Accept a readonly (`as const`) table properly ([#14565](https://github.com/jestjs/jest/pull/14565))
2627
- `[jest-snapshot]` [**BREAKING**] Add support for [Error causes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) in snapshots ([#13965](https://github.com/facebook/jest/pull/13965))
@@ -41,10 +42,12 @@
4142
- `[jest-config]` Support `testTimeout` in project config ([#14697](https://github.com/jestjs/jest/pull/14697))
4243
- `[jest-config]` Support `coverageReporters` in project config ([#14697](https://github.com/jestjs/jest/pull/14830))
4344
- `[jest-config]` Allow `reporters` in project config ([#14768](https://github.com/jestjs/jest/pull/14768))
45+
- `[jest-each]` Allow `$keypath` templates with `null` or `undefined` values ([#14831](https://github.com/jestjs/jest/pull/14831))
4446
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
4547
- `[@jest/expect-utils]` [**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670))
4648
- `[@jest/expect-utils]` Fix comparison of `URL` ([#14672](https://github.com/jestjs/jest/pull/14672))
4749
- `[@jest/expect-utils]` Check `Symbol` properties in equality ([#14688](https://github.com/jestjs/jest/pull/14688))
50+
- `[@jest/expect-utils]` Catch circular references within arrays when matching objects ([#14894](https://github.com/jestjs/jest/pull/14894))
4851
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
4952
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
5053
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
@@ -57,7 +60,7 @@
5760
### Performance
5861

5962
- `[*]` [**BREAKING**] Bundle all of Jest's modules into `index.js` ([#12348](https://github.com/jestjs/jest/pull/12348), [#14550](https://github.com/jestjs/jest/pull/14550) & [#14661](https://github.com/jestjs/jest/pull/14661))
60-
- `[*]` [jest-haste-map] Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))
63+
- `[jest-haste-map]` Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))
6164

6265
### Chore & Maintenance
6366

@@ -74,11 +77,13 @@
7477
- `[jest-cli, jest-config, @jest/types]` [**BREAKING**] Remove deprecated `--init` argument ([#14490](https://github.com/jestjs/jest/pull/14490))
7578
- `[jest-config, @jest/core, jest-util]` Upgrade `ci-info` ([#14655](https://github.com/jestjs/jest/pull/14655))
7679
- `[jest-mock]` [**BREAKING**] Remove `MockFunctionMetadataType`, `MockFunctionMetadata` and `SpyInstance` types ([#14621](https://github.com/jestjs/jest/pull/14621))
80+
- `[@jest/reporters]` Upgrade `istanbul-lib-source-maps` ([#14924](https://github.com/jestjs/jest/pull/14924))
7781
- `[jest-schemas]` Upgrade `@sinclair/typebox` ([#14775](https://github.com/jestjs/jest/pull/14775))
7882
- `[jest-transform]` Upgrade `write-file-atomic` ([#14274](https://github.com/jestjs/jest/pull/14274))
79-
- `[jest-util]` Upgrade `picomatch` to v3 ([#14653](https://github.com/jestjs/jest/pull/14653))
83+
- `[jest-util]` Upgrade `picomatch` to v4 ([#14653](https://github.com/jestjs/jest/pull/14653) & [#14885](https://github.com/jestjs/jest/pull/14885))
8084
- `[docs] Append to NODE_OPTIONS, not overwrite ([#14730](https://github.com/jestjs/jest/pull/14730))`
8185
- `[docs]` Updated `.toHaveBeenCalled()` documentation to correctly reflect its functionality ([#14842](https://github.com/jestjs/jest/pull/14842))
86+
- `[docs]` Link NestJS documentation on testing with Jest ([#14940](https://github.com/jestjs/jest/pull/14940))
8287

8388
## 29.7.0
8489

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) Meta Platforms, Inc. and affiliates.
4+
Copyright Contributors to the Jest project.
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
- [Backers](#backers)
5454
- [Sponsors](#sponsors)
5555
- [License](#license)
56+
- [Copyright](#copyright)
5657

5758
## Getting Started
5859

@@ -276,3 +277,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
276277
## License
277278

278279
Jest is [MIT licensed](./LICENSE).
280+
281+
## Copyright
282+
283+
Copyright Contributors to the Jest project.

SECURITY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Reporting a Vulnerability
2+
3+
If you discover a security vulnerability within Jest, please submit a report via the GitHub's [Private Vulnerability Reporting](https://github.com/jestjs/jest/security/advisories) feature.
4+
5+
All security vulnerabilities will be promptly addressed.

docs/TestingFrameworks.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Jest is a universal testing platform, with the ability to adapt to any JavaScrip
4747
## Next.js
4848

4949
- [Jest and React Testing Library](https://nextjs.org/docs/pages/building-your-application/testing/jest) by Next.js docs
50+
51+
## NestJS
52+
53+
- [Jest and NestJS dependencies](https://docs.nestjs.com/fundamentals/testing#unit-testing) by NestJS docs

e2e/__tests__/__snapshots__/each.test.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`allows nullable or undefined args when templating object each args 1`] = `
4+
"PASS __tests__/eachTemplate.test.js
5+
✓ allows templating "value"
6+
✓ allows templating "null"
7+
✓ allows templating "undefined"
8+
✓ allows templating "1"
9+
✓ allows templating "null"
10+
✓ allows templating "undefined""
11+
`;
12+
313
exports[`formats args with pretty format when given %p 1`] = `
414
"PASS __tests__/pretty.test.js
515
array
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
describe('matches circular references nested in:', () => {
9+
interface CircularObj {
10+
ref: unknown;
11+
[prop: string]: unknown;
12+
}
13+
14+
test('arrays', () => {
15+
type CircularArray = CircularObj & {ref: Array<unknown>};
16+
17+
const a: CircularArray = {c: 1, ref: [1]};
18+
const b: CircularArray = {c: 1, ref: [1]};
19+
20+
a.ref.push(a);
21+
b.ref.push(b);
22+
expect(a).toMatchObject(b);
23+
24+
b.ref = [];
25+
expect(a).not.toMatchObject(b);
26+
27+
b.ref = [1];
28+
expect(a).not.toMatchObject(b);
29+
});
30+
31+
test('deeply nested array properties', () => {
32+
type DeepCircularArray = CircularObj & {ref: {inner: Array<unknown>}};
33+
const a: DeepCircularArray = {
34+
c: 1,
35+
ref: {
36+
inner: [1],
37+
},
38+
};
39+
const b: DeepCircularArray = {
40+
c: 1,
41+
ref: {
42+
inner: [1],
43+
},
44+
};
45+
a.ref.inner.push(a);
46+
b.ref.inner.push(b);
47+
expect(a).toMatchObject(b);
48+
49+
b.ref.inner = [];
50+
expect(a).not.toMatchObject(b);
51+
52+
b.ref.inner = [1];
53+
expect(a).not.toMatchObject(b);
54+
});
55+
56+
test('sets', () => {
57+
type CircularSet = CircularObj & {ref: Set<unknown>};
58+
59+
const a: CircularSet = {c: 1, ref: new Set()};
60+
const b: CircularSet = {c: 1, ref: new Set()};
61+
62+
a.ref.add(a);
63+
b.ref.add(b);
64+
expect(a).toMatchObject(b);
65+
66+
b.ref.clear();
67+
expect(a).not.toMatchObject(b);
68+
69+
b.ref.add(1);
70+
expect(a).not.toMatchObject(b);
71+
});
72+
73+
test('maps', () => {
74+
type CircularMap = CircularObj & {ref: Map<string, unknown>};
75+
76+
const a: CircularMap = {c: 1, ref: new Map()};
77+
const b: CircularMap = {c: 1, ref: new Map()};
78+
79+
a.ref.set('innerRef', a);
80+
b.ref.set('innerRef', b);
81+
expect(a).toMatchObject(b);
82+
83+
b.ref.clear();
84+
expect(a).not.toMatchObject(b);
85+
86+
b.ref.set('innerRef', 1);
87+
expect(a).not.toMatchObject(b);
88+
});
89+
});

e2e/__tests__/each.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ test('formats args with pretty format when given %p', () => {
6060
expect(rest).toMatchSnapshot();
6161
expect(result.exitCode).toBe(0);
6262
});
63+
64+
test('allows nullable or undefined args when templating object each args', () => {
65+
const result = runJest(dir, ['eachTemplate.test.js']);
66+
const {rest} = extractSummary(result.stderr);
67+
expect(rest).toMatchSnapshot();
68+
expect(result.exitCode).toBe(0);
69+
});

0 commit comments

Comments
 (0)