From b954a14058378449c4046c0d703118a12db4dcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=E2=84=93e=20Hensel?= Date: Tue, 6 May 2025 13:11:55 +1000 Subject: [PATCH] chore(snapshots): rename `message` to `hint` in method signatures (#7919) --- docs/api/expect.md | 10 +++++----- packages/vitest/src/types/global.ts | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/api/expect.md b/docs/api/expect.md index 57af519d8..f8ecd2ace 100644 --- a/docs/api/expect.md +++ b/docs/api/expect.md @@ -771,7 +771,7 @@ test('throws on pineapples', async () => { ## toMatchSnapshot -- **Type:** `(shape?: Partial | string, message?: string) => void` +- **Type:** `(shape?: Partial | string, hint?: string) => void` This ensures that a value matches the most recent snapshot. @@ -803,7 +803,7 @@ test('matches snapshot', () => { ## toMatchInlineSnapshot -- **Type:** `(shape?: Partial | string, snapshot?: string, message?: string) => void` +- **Type:** `(shape?: Partial | string, snapshot?: string, hint?: string) => void` This ensures that a value matches the most recent snapshot. @@ -846,7 +846,7 @@ test('matches snapshot', () => { ## toMatchFileSnapshot {#tomatchfilesnapshot} -- **Type:** `(filepath: string, message?: string) => Promise` +- **Type:** `(filepath: string, hint?: string) => Promise` Compare or update the snapshot with the content of a file explicitly specified (instead of the `.snap` file). @@ -863,13 +863,13 @@ Note that since file system operation is async, you need to use `await` with `to ## toThrowErrorMatchingSnapshot -- **Type:** `(message?: string) => void` +- **Type:** `(hint?: string) => void` The same as [`toMatchSnapshot`](#tomatchsnapshot), but expects the same value as [`toThrowError`](#tothrowerror). ## toThrowErrorMatchingInlineSnapshot -- **Type:** `(snapshot?: string, message?: string) => void` +- **Type:** `(snapshot?: string, hint?: string) => void` The same as [`toMatchInlineSnapshot`](#tomatchinlinesnapshot), but expects the same value as [`toThrowError`](#tothrowerror). diff --git a/packages/vitest/src/types/global.ts b/packages/vitest/src/types/global.ts index 47a38e083..d42eac089 100644 --- a/packages/vitest/src/types/global.ts +++ b/packages/vitest/src/types/global.ts @@ -19,18 +19,18 @@ declare global { interface SnapshotMatcher { ( snapshot: Partial, - message?: string + hint?: string ): void - (message?: string): void + (hint?: string): void } interface InlineSnapshotMatcher { ( properties: Partial, snapshot?: string, - message?: string + hint?: string ): void - (message?: string): void + (hint?: string): void } declare module '@vitest/expect' { @@ -67,19 +67,19 @@ declare module '@vitest/expect' { /** * Checks that an error thrown by a function matches a previously recorded snapshot. * - * @param message - Optional custom error message. + * @param hint - Optional custom error message. * * @example * expect(functionWithError).toThrowErrorMatchingSnapshot(); */ - toThrowErrorMatchingSnapshot: (message?: string) => void + toThrowErrorMatchingSnapshot: (hint?: string) => void /** * Checks that an error thrown by a function matches an inline snapshot within the test file. * Useful for keeping snapshots close to the test code. * * @param snapshot - Optional inline snapshot string to match. - * @param message - Optional custom error message. + * @param hint - Optional custom error message. * * @example * const throwError = () => { throw new Error('Error occurred') }; @@ -87,7 +87,7 @@ declare module '@vitest/expect' { */ toThrowErrorMatchingInlineSnapshot: ( snapshot?: string, - message?: string + hint?: string ) => void /** @@ -95,12 +95,12 @@ declare module '@vitest/expect' { * Useful for cases where snapshot content is large or needs to be shared across tests. * * @param filepath - Path to the snapshot file. - * @param message - Optional custom error message. + * @param hint - Optional custom error message. * * @example * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json'); */ - toMatchFileSnapshot: (filepath: string, message?: string) => Promise + toMatchFileSnapshot: (filepath: string, hint?: string) => Promise } } -- 2.51.2