erikras / erikras/react-redux-universal-hot-example

API unit tests are very slow due to setTimeout on widget code

Open
#876 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Unit tests on the API are very, very slow. I started playing around with adding a bit more test coverage, but had to disable the widget tests while working because of the intentional 1-1.5 second timeouts.

Normally I'd stub something out if it's slow, or use nock to mock out a network request, but this isn't a real request.

I can make a pull request to bypass the delay, but I'm curious of your opinion on the possible approaches:
- Change the code to use a different delay based on environment (test/dev/prod).
- Change the code to accept an argument for delay.
- Use sinon.useFakeTimers(). This will completely isolate changes to tests, but is very brute-force and can have unexpected effects on any libraries using setTimeout / setImmediate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.