TheBrainFamily / wait-for-expect

Wait for expectation to be true, useful for integration and end to end testing. Integral part of react-testing-library.
MIT License
293 stars 31 forks source link

setTimeout is called after reject #10

Closed iceberk closed 6 years ago

iceberk commented 6 years ago

Hello,

I am running mocha tests in 'watch' mode and noticed that expectations are still being checked after timeout and test failure, because there is no return after reject(error) in waitForExpect and setTimout is called again and again. Is it intended behaviour?

kentcdodds commented 6 years ago

Ah, that's interesting. I think there should be a return on or after this line:

https://github.com/TheBrainFamily/wait-for-expect/blob/e910af64c054eda3bd4cf5931c3e296d419504ff/src/index.ts#L22

What do you think @lgandecki?

lgandecki commented 6 years ago

Good catch!

@iceberk do you want to become a contributor to this tiny package? ;-) Otherwise I will make the change today or tomorrow.

iceberk commented 6 years ago

Sure, will try to send a request today.

lgandecki commented 6 years ago

fixed in 1.0.1 , thanks @iceberk and thanks @kentcdodds !