diff --git a/CHANGELOG.md b/CHANGELOG.md index c640ada15d9a..0d563fab9e04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - `[jest-core]` Add support for `testResultsProcessor` written in ESM ([#12006](https://github.com/facebook/jest/pull/12006)) - `[jest-diff, pretty-format]` Add `compareKeys` option for custom sorting of object keys ([#11992](https://github.com/facebook/jest/pull/11992)) -- `[jest-mock]` Add `ts-jest` mock util functions ([#12089](https://github.com/facebook/jest/pull/12089)) +- `[jest-mock]` Add `ts-jest` mock util functions ([#12089](https://github.com/facebook/jest/pull/12089)) ### Fixes diff --git a/docs/JestObjectAPI.md b/docs/JestObjectAPI.md index b724d82c51b1..c4cd184b5661 100644 --- a/docs/JestObjectAPI.md +++ b/docs/JestObjectAPI.md @@ -597,32 +597,31 @@ export const foo = { }, }, name: () => 'foo', -} +}; ``` ```ts // foo.spec.ts -import { foo } from './foo' -jest.mock('./foo') +import {foo} from './foo'; +jest.mock('./foo'); // here the whole foo var is mocked deeply -const mockedFoo = jest.mocked(foo, true) +const mockedFoo = jest.mocked(foo, true); test('deep', () => { // there will be no TS error here, and you'll have completion in modern IDEs - mockedFoo.a.b.c.hello('me') + mockedFoo.a.b.c.hello('me'); // same here - expect(mockedFoo.a.b.c.hello.mock.calls).toHaveLength(1) -}) + expect(mockedFoo.a.b.c.hello.mock.calls).toHaveLength(1); +}); test('direct', () => { - foo.name() + foo.name(); // here only foo.name is mocked (or its methods if it's an object) - expect(mocked(foo.name).mock.calls).toHaveLength(1) -}) + expect(mocked(foo.name).mock.calls).toHaveLength(1); +}); ``` - ## Mock Timers ### `jest.useFakeTimers(implementation?: 'modern' | 'legacy')`