All files / src/tests hooks.ts

100% Statements 11/11
75% Branches 6/8
100% Functions 2/2
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1822x 1x 1x 1x 1x   1x     78x       78x 78x   1x  
import { request, testRoute } from "@cooper/backend/src/tests/utils";
import { generateMock } from "@anatine/zod-mock";
import { Auth$UserSchema } from "@cooper/ts-rest/src/types";
import { seed } from "@cooper/backend/src/tests/mocking";
import { contract } from "@cooper/ts-rest/src/contract";
 
export const mochaHooks = {
  // Runs before every test in every file
  beforeEach: async function () {
    await request().get("/testing/reset").expect(200);
 
    // Create a new initial user for use in tests on protected routes
    // Simplifies other tests by removing need to do this step
    const mockUser = generateMock(Auth$UserSchema, { seed });
    await testRoute(request(), contract.public.auth.signup).send(mockUser).expect(200);
  },
};