Back to home

msw/

mock

Version: 0.0.1

Last Updated: Unknown


Msw - Mock

Use this tempalate to create a mock using the createMock helper.

Required

VariableData TypeInfo
namestringName for the mock
routestringRoute to mock

Module files

1import {
2 createMock,
3 GraphQLResolver,
4 mockError,
5 mockSuccess,
6 RestResolver,
7 } from "../../../utils";
8
9 const handleQuery: GraphQLResolver = (_req, res, ctx) => {
10 return res(
11 ctx.status(500),
12 ctx.data({
13 message: "error",
14 })
15 );
16 };
17
18 const handleGet: RestResolver = (_req, res, ctx) => {
19 return res(
20 ctx.status(500),
21 ctx.json({
22 message: "error",
23 })
24 );
25 };
26
27 export const <%= _.camelCase(name) %>Mock = createMock({
28 name: "<%= _.upperFirst(_.camelCase(name)) %>",
29 route: "<%= route %>",
30 mocks: {
31 get: handleGet,
32 put: mockSuccess,
33 post: mockError,
34 query: handleQuery,
35 },
36 });

Install


Lift generate


Repository

https://github.com/okeeffed/pkg-lift-msw

Sections