mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
49b8e7329e
* refactor: replace data-test with data-testid * refactor: add Jest tests for auth pages * refactor: remove Cypress tests for auth pages * refactor: remove questionable snapshots * refactor: share test server setup/teardown * refactor: restore auth page flex layout * refactor: use toBeInTheDocument * refactor: change recent data-test attrs to data-testid
25 lines
542 B
TypeScript
25 lines
542 B
TypeScript
import { SetupServerApi, setupServer } from 'msw/node';
|
|
import { rest } from 'msw';
|
|
|
|
export const testServerSetup = (): SetupServerApi => {
|
|
const server = setupServer();
|
|
|
|
beforeAll(() => server.listen());
|
|
afterAll(() => server.close());
|
|
afterEach(() => server.resetHandlers());
|
|
|
|
return server;
|
|
};
|
|
|
|
export const testServerRoute = (
|
|
server: SetupServerApi,
|
|
path: string,
|
|
json: object
|
|
) => {
|
|
server.use(
|
|
rest.get(path, (req, res, ctx) => {
|
|
return res(ctx.json(json));
|
|
})
|
|
);
|
|
};
|