Commit 443b0d96 authored by David Sveningsson's avatar David Sveningsson
Browse files

Merge branch 'bugfix/vitest-augmentation' into 'master'

vitest augmentation

See merge request !1399
parents 27c637e4 39606031
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
    "allowJs": true,
    "checkJs": true,

    "skipLibCheck": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "noImplicitAny": true,
+2 −2
Original line number Diff line number Diff line
@@ -93,10 +93,10 @@
      },
      "peerDependencies": {
        "@jest/globals": "^29.0.3 || ^30.0.0",
        "@vitest/expect": "^3.0.0 || ^4.0.1",
        "@vitest/expect": "^3.2.0 || ^4.0.1",
        "jest": "^29.0.3 || ^30.0.0",
        "jest-snapshot": "^29.0.3 || ^30.0.0",
        "vitest": "^3.0.0 || ^4.0.1"
        "vitest": "^3.2.0 || ^4.0.1"
      },
      "peerDependenciesMeta": {
        "@jest/globals": {
+2 −2
Original line number Diff line number Diff line
@@ -285,10 +285,10 @@
  },
  "peerDependencies": {
    "@jest/globals": "^29.0.3 || ^30.0.0",
    "@vitest/expect": "^3.0.0 || ^4.0.1",
    "@vitest/expect": "^3.2.0 || ^4.0.1",
    "jest": "^29.0.3 || ^30.0.0",
    "jest-snapshot": "^29.0.3 || ^30.0.0",
    "vitest": "^3.0.0 || ^4.0.1"
    "vitest": "^3.2.0 || ^4.0.1"
  },
  "peerDependenciesMeta": {
    "@jest/globals": {
+68 −4
Original line number Diff line number Diff line
@@ -43,10 +43,74 @@ declare module "vitest" {
		 *
		 * @since 8.5.0
		 */
		toHTMLValidate(filename?: string): T;
		toHTMLValidate(config: ConfigData, filename?: string): T;
		toHTMLValidate(error: Partial<Message>, filename?: string): T;
		toHTMLValidate(error: Partial<Message>, config: ConfigData, filename?: string): T;
		toHTMLValidate(filename?: string): Promise<void>;
		toHTMLValidate(config: ConfigData, filename?: string): Promise<void>;
		toHTMLValidate(error: Partial<Message>, filename?: string): Promise<void>;
		toHTMLValidate(error: Partial<Message>, config: ConfigData, filename?: string): Promise<void>;

		/**
		 * Writes out the given [[Report]] using codeframe formatter and compares
		 * with snapshot.
		 *
		 * * Requires Vitest v4.1.3 or later.
		 *
		 * @since 11.2.0
		 */
		toMatchCodeframe(hint?: string): Promise<void>;

		/**
		 * Writes out the given [[Report]] using codeframe formatter and compares
		 * with inline snapshot.
		 *
		 * Requires Vitest v4.1.3 or later.
		 *
		 * @since 11.2.0
		 */
		toMatchInlineCodeframe(snapshot?: string): Promise<void>;
	}

	/* eslint-disable-next-line @typescript-eslint/no-explicit-any -- to match upstream */
	interface Matchers<T = any> {
		/**
		 * @since 8.5.0
		 */
		toBeValid(): Promise<void>;

		/**
		 * @since 8.5.0
		 */
		toBeInvalid(): Promise<void>;

		/**
		 * @since 8.5.0
		 */
		toHaveError(error: Partial<Message>): T;

		/**
		 * @since 8.5.0
		 */
		toHaveError(ruleId: string, message: string, context?: unknown): T;

		/**
		 * @since 8.5.0
		 */
		toHaveErrors(errors: Array<[string, string] | Record<string, unknown>>): T;

		/**
		 * Validate string or HTMLElement.
		 *
		 * Test passes if result is valid.
		 *
		 * @param config - Optional HTML-Validate configuration object.
		 * @param filename - Optional filename used when matching transformer and
		 * loading configuration.
		 *
		 * @since 8.5.0
		 */
		toHTMLValidate(filename?: string): Promise<void>;
		toHTMLValidate(config: ConfigData, filename?: string): Promise<void>;
		toHTMLValidate(error: Partial<Message>, filename?: string): Promise<void>;
		toHTMLValidate(error: Partial<Message>, config: ConfigData, filename?: string): Promise<void>;

		/**
		 * Writes out the given [[Report]] using codeframe formatter and compares
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import { reportError, reportErrorAsync } from "./__fixtures__";
import { toHaveError } from "./to-have-error";

expect.extend({
	/* @ts-expect-error technical debt, vitest/jest types clashes */
	toHaveError: toHaveError(expect),
});

Loading