lorenzofox3/zora

Debounced method blocks test completion

Closed this issue · 2 comments

I have prepared a minimal (probably) example: https://github.com/Alexey-Sch/zora-bug

Calling the function that is indicated by the link: https://github.com/Alexey-Sch/zora-bug/blob/master/tests/test.js#L37

It shouldn't interfere with the completion of the test, should it? I expect his call to go unnoticed. In reality, the test takes 30 seconds. If I wanted the method to take that long, I would use the done callback approach.

In Jest, execution would go to this line: https://github.com/Alexey-Sch/zora-bug/blob/master/tests/test.js#L39 and the test would end immediately.

This has nothing to do with zora.

The test does not take 30s to complete, the node process indeed does take 30s to complete because you add a timeout in the event loop.

try to run

const dt = require('throttle-debounce');

const debounced = dt.debounce(30000, () => console.log('ok!'));

debounced();

you'll get the same behavior

If Jest shuts down your process, I would be a bit concerned: what about closing db connection etc ...

Yes, their documentation states that after executing each test, it is recommended to clean up the data in beforeAll/beforeEach. The question is cleared.