-
-
Notifications
You must be signed in to change notification settings - Fork 209
Open
Description
I'd like to see an example test that resets the handlers between tests and configures a unique response per test.
My understanding is that I should be able to add an "override" handler in individual tests that tweak a default configuration.
Here is some pseudo-code that represents what I think is needed for setup / use.
setupTests.js
import { handlers } from './mocks'
const server = setupServer(...handlers)
beforeAll(() => {
server.listen()
})
afterEach(() => {
server.resetHandlers()
})
afterAll(() => {
server.close()
})
Test:
// Appropriate imports here to get access to server
it('Uses default setup', () => {
// Test here
}
it('Uses custom setup', () => {
server.use(
graphql.query('SameQueryAsSetup`, (req, res, ctx) => {
// Return different response from default
});
// Rest of test
}
danielbayerlein
Metadata
Metadata
Assignees
Labels
No labels