Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setupServer: use timers module #243

Merged
merged 4 commits into from Jun 24, 2020
Merged

setupServer: use timers module #243

merged 4 commits into from Jun 24, 2020

Conversation

kentcdodds
Copy link
Contributor

This is all that needs to be done to avoid issues with this code:

test('tolerates fake timers', async () => {
  server.use(
    rest.get('https://test.mswjs.io/pull', (req, res, ctx) => {
      return res(ctx.json({status: 'pulled'}))
    }),
  )
  jest.useFakeTimers()

  const res = await fetch('https://test.mswjs.io/pull')
  const body = await res.json()

  jest.useRealTimers()

  expect(body).toEqual({status: 'pulled'})
})

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy that you've figured out the right solution to this! Thank you and welcome to contributors! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants