Replies: 1 comment
-
How it could look like in node environment, inspired by https://github.com/apollographql/graphql-testing-library import { createMswHandler } from "counterpart";
import counterpartConfig from "../counterpartConfig.json";
const { handler, replaceHandlers } = createMswHandler(counterpartConfig, {
// msw config
delay: number | "infinite" | "real",
});
// setup
import { setupServer } from 'msw/node';
import { handler } from './counterpartHandler';
export const server = setupServer(handler);
// usage
describe('MyComponent', () => {
it('should make API request', () => {
using _disposed = replaceHandlers({
'user/{userId}': ($) => $.response[200].random(),
});
render(<MyComponent />);
});
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it's a good idea to use counterfact in integration tests.
So, it could integrate into the MSW server and provide the ability to override a request for a specific test case with type safety.
Beta Was this translation helpful? Give feedback.
All reactions