nicolo-ribaudo / jest-light-runner

A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment.
MIT License
227 stars 24 forks source link

jest.setTimeout is not a function #36

Open perrin4869 opened 2 years ago

perrin4869 commented 2 years ago

I've been trying to migrate a module to using this test runner (thank you so much!). Unfortunately I got stuck behind an error: TypeError: jest.setTimeout is not a function I am not sure if this is a problem in this repo to be honest, but suspect it might not be supported here? If so, is there an alternative? Thanks!

Zikoat commented 1 year ago

The fix in my case was to just remove the call to jest.setTimeout and let the test run.

In the normal jest runner the test fails after 5 seconds, and then you have to run jest.setTimeout(20 * 1000) to make it run for 20 seconds before failing. In jest-light-runner the behavior is to not fail the test after 5 seconds, but to keep it running indefinitely until it resolves. Just removing the call to jest.setTimeout is a temporary fix, but this might break the pipeline if there are some promises that never resolve.

Having a promise that never resolves might happen if the test is run as an integration test, and an update in the test causes a deadlock in the database. In this case the test will never fail, and if it additionally is run in the pipeline it will keep the pipeline from completing. So it would be nice if this feature would be implemented, or that this different behavior is at least documented in the readme.