Files
test/backend/__tests__/vitest.d.ts
Benjamin Falch 2bc741fb78
Some checks failed
Mark Stale PRs / stale (push) Has been cancelled
adding monkeytype
2026-04-23 13:53:44 +02:00

33 lines
871 B
TypeScript

import type { Assertion, AsymmetricMatchersContaining } from "vitest";
import type { Test as SuperTest } from "supertest";
import MonkeyError from "../src/utils/error";
type ExpectedRateLimit = {
/** max calls */
max: number;
/** window in milliseconds. Needs to be within 2500ms */
windowMs: number;
};
interface RestRequestMatcher<R = Supertest> {
toBeRateLimited: (expected: ExpectedRateLimit) => RestRequestMatcher<R>;
}
interface ThrowMatcher {
toMatchMonkeyError: (expected: {
status: number;
message: string;
}) => MatcherResult;
}
declare module "vitest" {
interface Assertion<T = any> extends RestRequestMatcher<T>, ThrowMatcher {}
interface AsymmetricMatchersContaining
extends RestRequestMatcher, ThrowMatcher {}
}
interface MatcherResult {
pass: boolean;
message: () => string;
actual?: unknown;
expected?: unknown;
}