From 0db8bf61ec3f08f6c91bb6793c0c75193fb346ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:56:56 +0200 Subject: [PATCH 1/5] chore(deps): bump postcss from 8.4.30 to 8.4.31 in /website (#660) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- website/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/yarn.lock b/website/yarn.lock index 1b28e7af..5c2a0122 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -6243,9 +6243,9 @@ postcss-zindex@^5.1.0: integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A== postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.21: - version "8.4.30" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.30.tgz#0e0648d551a606ef2192a26da4cabafcc09c1aa7" - integrity sha512-7ZEao1g4kd68l97aWG/etQKPKq07us0ieSZ2TnFDk11i0ZfDW2AwKHYU8qv4MZKqN2fdBfg+7q0ES06UA73C1g== + version "8.4.31" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d" + integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ== dependencies: nanoid "^3.3.6" picocolors "^1.0.0" From 9231e42aa8fda4355ab562fe037f7e6cb702009e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Mon, 9 Oct 2023 09:28:54 -0400 Subject: [PATCH 2/5] Mark toHaveBeenCalledBefore and After's second parameter as optional (#650) * Mark toHaveBeenCalledBefore's second parameter as optional `toHaveBeenCalledBefore`'s first parameter should be optional because it has a default value. * Mark toHaveBeenCalledAfter's second parameter as optional --- types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index a0cef966..9436c25c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -146,7 +146,7 @@ interface CustomMatchers extends Record { * @param {Mock} mock * @param {boolean} [failIfNoSecondInvocation=true] */ - toHaveBeenCalledBefore(mock: jest.MockInstance, failIfNoSecondInvocation: boolean): R; + toHaveBeenCalledBefore(mock: jest.MockInstance, failIfNoSecondInvocation?: boolean): R; /** * Use `.toHaveBeenCalledAfter` when checking if a `Mock` was called after another `Mock`. @@ -156,7 +156,7 @@ interface CustomMatchers extends Record { * @param {Mock} mock * @param {boolean} [failIfNoFirstInvocation=true] */ - toHaveBeenCalledAfter(mock: jest.MockInstance, failIfNoFirstInvocation: boolean): R; + toHaveBeenCalledAfter(mock: jest.MockInstance, failIfNoFirstInvocation?: boolean): R; /** * Use `.toHaveBeenCalledOnce` to check if a `Mock` was called exactly one time. From 1f881015bf0daeebaa9292fb285f197854c3dad9 Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Mon, 9 Oct 2023 09:47:37 -0400 Subject: [PATCH 3/5] Changeset for #650 --- .changeset/ninety-dolphins-shake.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/ninety-dolphins-shake.md diff --git a/.changeset/ninety-dolphins-shake.md b/.changeset/ninety-dolphins-shake.md new file mode 100644 index 00000000..f47f35ca --- /dev/null +++ b/.changeset/ninety-dolphins-shake.md @@ -0,0 +1,5 @@ +--- +'jest-extended': patch +--- + +Mark 2nd param of toHaveBeenCalledBefore and toHaveBeenCalledAfter optional From bc75d104eb97c5cdf3d050aa4c53187580e174bd Mon Sep 17 00:00:00 2001 From: Keegan Witt Date: Mon, 9 Oct 2023 18:08:42 -0400 Subject: [PATCH 4/5] Update Vitest Typescript documentation (closes #649) (#662) Co-authored-by: Christopher Dierkens --- website/docs/getting-started/setup.md | 60 +++++++++++++++++++-------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/website/docs/getting-started/setup.md b/website/docs/getting-started/setup.md index 20e7f20b..e09e7a03 100644 --- a/website/docs/getting-started/setup.md +++ b/website/docs/getting-started/setup.md @@ -60,38 +60,62 @@ export default defineConfig({ To use Vitest with TypeScript, create a file named `jest-extended.d.ts` with the content below in addition to the setup above. +#### Vitest >= 0.31.0 + ```typescript -/// +import type CustomMatchers from 'jest-extended'; +import 'vitest'; + +declare module 'vitest' { + interface Assertion extends CustomMatchers {} + interface AsymmetricMatchersContaining extends CustomMatchers {} + interface ExpectStatic extends CustomMatchers {} +} +``` -export interface CustomMatchers extends Record { - toHaveBeenCalledAfter( - mock: jest.MockInstance | import('vitest').MockInstance, - failIfNoFirstInvocation?: boolean, - ): R; +This can be combined with matchers from other dependencies or your own custom matchers. Here's an example of a custom matcher. - toHaveBeenCalledBefore( - mock: jest.MockInstance | import('vitest').MockInstance, - failIfNoSecondInvocation?: boolean, - ): R; +```typescript +import type CustomMatchers from 'jest-extended'; +import 'vitest'; - toHaveBeenCalledExactlyOnceWith(...args: unknown[]): R; +interface MyCustomMatchers { + toBeFoo(): any; +} + +declare module 'vitest' { + interface Assertion extends CustomMatchers, MyCustomMatchers {} + interface AsymmetricMatchersContaining extends CustomMatchers, MyCustomMatchers {} + interface ExpectStatic extends CustomMatchers, MyCustomMatchers {} } ``` -For Vitest >= 0.31.0, append the content below to the new file. +#### Vitest < 0.31.0 ```typescript -declare module 'vitest' { - // eslint-disable-next-line @typescript-eslint/no-empty-interface +import type CustomMatchers from 'jest-extended'; +import 'vi'; + +declare module 'vi' { interface Assertion extends CustomMatchers {} + interface AsymmetricMatchersContaining extends CustomMatchers {} + interface ExpectStatic extends CustomMatchers {} } ``` -For Vitest < 0.31.0, append the content below to the new file. +This can be combined with matchers from other dependencies or your own custom matchers. Here's an example of a custom matcher. ```typescript -declare namespace Vi { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface AsymmetricMatchersContaining extends CustomMatchers {} +import type CustomMatchers from 'jest-extended'; +import 'vi'; + +interface MyCustomMatchers { + toBeFoo(): any; +} + +declare module 'vi' { + interface Assertion extends CustomMatchers, MyCustomMatchers {} + interface AsymmetricMatchersContaining extends CustomMatchers, MyCustomMatchers {} + interface ExpectStatic extends CustomMatchers, MyCustomMatchers {} } ``` From c8a31132cf2ccdfc1373d948d7ec299aea7fdfb9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 21:22:45 -0400 Subject: [PATCH 5/5] Version Packages (#661) Co-authored-by: github-actions[bot] --- .changeset/ninety-dolphins-shake.md | 5 ----- CHANGELOG.md | 6 ++++++ package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/ninety-dolphins-shake.md diff --git a/.changeset/ninety-dolphins-shake.md b/.changeset/ninety-dolphins-shake.md deleted file mode 100644 index f47f35ca..00000000 --- a/.changeset/ninety-dolphins-shake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'jest-extended': patch ---- - -Mark 2nd param of toHaveBeenCalledBefore and toHaveBeenCalledAfter optional diff --git a/CHANGELOG.md b/CHANGELOG.md index 632012af..f9229e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # jest-extended +## 4.0.2 + +### Patch Changes + +- 1f88101: Mark 2nd param of toHaveBeenCalledBefore and toHaveBeenCalledAfter optional + ## 4.0.1 ### Patch Changes diff --git a/package.json b/package.json index 5c61a94c..c32684b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jest-extended", - "version": "4.0.1", + "version": "4.0.2", "description": "Additional Jest matchers", "main": "dist/index.js", "types": "types/index.d.ts",