I have a integration test related to JWT on Express.js server. I want to add a test case on expired
JWT. So I use sinon to inject a fake timer. After I added the fake timer, the whole integration test
stop in the middle and give no response.
After investigation, I found out reason and the explanation in this Github issue.
It is because Express.js dependent on the global time function which is mocked by fake timer. As
“time” is frozen, the server does not run and give no response.
The solution is to set shouldAdvanceTime
to true in fake timer’s config. Mock the timer, without
freezing the time.