Skip to content

Commit

Permalink
Merge branch 'main' into improve-each-template-literal-infer
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Mar 17, 2024
2 parents bdf450c + 375b3ee commit b4af639
Show file tree
Hide file tree
Showing 69 changed files with 4,655 additions and 3,908 deletions.
344 changes: 172 additions & 172 deletions .yarn/releases/yarn-3.8.0.cjs → .yarn/releases/yarn-3.8.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.8.0.cjs
yarnPath: .yarn/releases/yarn-3.8.1.cjs
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
- `[@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))
- `[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))
- `[jest-runtime]` Exposing new modern timers function `jest.advanceTimersToFrame()` from `@jest/fake-timers` ([#14598](https://github.com/jestjs/jest/pull/14598))
- `[jest-runtime]` Support `import.meta.filename` and `import.meta.dirname` (available from [Node 20.11](https://nodejs.org/en/blog/release/v20.11.0))
- `[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))
- `[jest-runtime]` Support `import.meta.resolve` ([#14930](https://github.com/jestjs/jest/pull/14930))
- `[@jest/schemas]` Upgrade `@sinclair/typebox` to v0.31 ([#14072](https://github.com/jestjs/jest/pull/14072))
- `[@jest/types]` `test.each()`: Accept a readonly (`as const`) table properly ([#14565](https://github.com/jestjs/jest/pull/14565))
- `[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))
Expand All @@ -41,10 +42,12 @@
- `[jest-config]` Support `testTimeout` in project config ([#14697](https://github.com/jestjs/jest/pull/14697))
- `[jest-config]` Support `coverageReporters` in project config ([#14697](https://github.com/jestjs/jest/pull/14830))
- `[jest-config]` Allow `reporters` in project config ([#14768](https://github.com/jestjs/jest/pull/14768))
- `[jest-each]` Allow `$keypath` templates with `null` or `undefined` values ([#14831](https://github.com/jestjs/jest/pull/14831))
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
- `[@jest/expect-utils]` [**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670))
- `[@jest/expect-utils]` Fix comparison of `URL` ([#14672](https://github.com/jestjs/jest/pull/14672))
- `[@jest/expect-utils]` Check `Symbol` properties in equality ([#14688](https://github.com/jestjs/jest/pull/14688))
- `[@jest/expect-utils]` Catch circular references within arrays when matching objects ([#14894](https://github.com/jestjs/jest/pull/14894))
- `[jest-leak-detector]` Make leak-detector more aggressive when running GC ([#14526](https://github.com/jestjs/jest/pull/14526))
- `[jest-runtime]` Properly handle re-exported native modules in ESM via CJS ([#14589](https://github.com/jestjs/jest/pull/14589))
- `[jest-util]` Make sure `isInteractive` works in a browser ([#14552](https://github.com/jestjs/jest/pull/14552))
Expand All @@ -57,7 +60,7 @@
### Performance

- `[*]` [**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))
- `[*]` [jest-haste-map] Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))
- `[jest-haste-map]` Only spawn one process to check for `watchman` installation ([#14826](https://github.com/jestjs/jest/pull/14826))

### Chore & Maintenance

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

## 29.7.0

Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- [Backers](#backers)
- [Sponsors](#sponsors)
- [License](#license)
- [Copyright](#copyright)

## Getting Started

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

Jest is [MIT licensed](./LICENSE).

## Copyright

Copyright Contributors to the Jest project.
5 changes: 5 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Reporting a Vulnerability

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.

All security vulnerabilities will be promptly addressed.
4 changes: 4 additions & 0 deletions docs/TestingFrameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ Jest is a universal testing platform, with the ability to adapt to any JavaScrip
## Next.js

- [Jest and React Testing Library](https://nextjs.org/docs/pages/building-your-application/testing/jest) by Next.js docs

## NestJS

- [Jest and NestJS dependencies](https://docs.nestjs.com/fundamentals/testing#unit-testing) by NestJS docs
10 changes: 10 additions & 0 deletions e2e/__tests__/__snapshots__/each.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`allows nullable or undefined args when templating object each args 1`] = `
"PASS __tests__/eachTemplate.test.js
✓ allows templating "value"
✓ allows templating "null"
✓ allows templating "undefined"
✓ allows templating "1"
✓ allows templating "null"
✓ allows templating "undefined""
`;

exports[`formats args with pretty format when given %p 1`] = `
"PASS __tests__/pretty.test.js
array
Expand Down
89 changes: 89 additions & 0 deletions e2e/__tests__/circularRefInBuiltInObj.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('matches circular references nested in:', () => {
interface CircularObj {
ref: unknown;
[prop: string]: unknown;
}

test('arrays', () => {
type CircularArray = CircularObj & {ref: Array<unknown>};

const a: CircularArray = {c: 1, ref: [1]};
const b: CircularArray = {c: 1, ref: [1]};

a.ref.push(a);
b.ref.push(b);
expect(a).toMatchObject(b);

b.ref = [];
expect(a).not.toMatchObject(b);

b.ref = [1];
expect(a).not.toMatchObject(b);
});

test('deeply nested array properties', () => {
type DeepCircularArray = CircularObj & {ref: {inner: Array<unknown>}};
const a: DeepCircularArray = {
c: 1,
ref: {
inner: [1],
},
};
const b: DeepCircularArray = {
c: 1,
ref: {
inner: [1],
},
};
a.ref.inner.push(a);
b.ref.inner.push(b);
expect(a).toMatchObject(b);

b.ref.inner = [];
expect(a).not.toMatchObject(b);

b.ref.inner = [1];
expect(a).not.toMatchObject(b);
});

test('sets', () => {
type CircularSet = CircularObj & {ref: Set<unknown>};

const a: CircularSet = {c: 1, ref: new Set()};
const b: CircularSet = {c: 1, ref: new Set()};

a.ref.add(a);
b.ref.add(b);
expect(a).toMatchObject(b);

b.ref.clear();
expect(a).not.toMatchObject(b);

b.ref.add(1);
expect(a).not.toMatchObject(b);
});

test('maps', () => {
type CircularMap = CircularObj & {ref: Map<string, unknown>};

const a: CircularMap = {c: 1, ref: new Map()};
const b: CircularMap = {c: 1, ref: new Map()};

a.ref.set('innerRef', a);
b.ref.set('innerRef', b);
expect(a).toMatchObject(b);

b.ref.clear();
expect(a).not.toMatchObject(b);

b.ref.set('innerRef', 1);
expect(a).not.toMatchObject(b);
});
});
7 changes: 7 additions & 0 deletions e2e/__tests__/each.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,10 @@ test('formats args with pretty format when given %p', () => {
expect(rest).toMatchSnapshot();
expect(result.exitCode).toBe(0);
});

test('allows nullable or undefined args when templating object each args', () => {
const result = runJest(dir, ['eachTemplate.test.js']);
const {rest} = extractSummary(result.stderr);
expect(rest).toMatchSnapshot();
expect(result.exitCode).toBe(0);
});
Loading

0 comments on commit b4af639

Please sign in to comment.