Skip to content

Commit 961fed8

Browse files
committed
add types for custom vitest assertions
1 parent ccc0c25 commit 961fed8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

server/tests/unit/api/room.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ describe("Room API", () => {
142142
.expect("Content-Type", /json/)
143143
.expect(404);
144144
expect(resp.body.success).toEqual(false);
145-
// @ts-expect-error I can't get typescript to acknowledge the custom matchers.
146145
expect(resp.body.error).toBeRoomNotFound();
147146
});
148147
});

server/tests/unit/vitest.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Assertion, AsymmetricMatchersContaining } from "vitest";
2+
3+
interface OttMatchers<R = unknown> {
4+
toBeRoomNotFound: () => R;
5+
toBeUnknownError: () => R;
6+
}
7+
8+
declare module "vitest" {
9+
interface Assertion<T = any> extends OttMatchers<T> {}
10+
interface AsymmetricMatchersContaining extends OttMatchers {}
11+
}

0 commit comments

Comments
 (0)