React-testing-library: Assertions On setTimeout When Using react-testing-library

Created on 16 Feb 2020  路  1Comment  路  Source: testing-library/react-testing-library

I posted this on StackOverflow a little over a week ago. Since I haven't received an answer there yet, I thought I'd ask here too.

I have a notification that appears and then disappears after 4 seconds. I'm using setTimeout to achieve this behavior. In my tests I'm trying to use jest.useFakeTimers and then expect the call to setTimeout. But I'm getting a lot of extra calls to setTimeout that I'm not expecting. I was finally able to track down that the calls are coming from the @sheerun/mutationobserver-shim package which looks like it's used in dom-testing-library.

Is there a way to assert on the number of calls to setTimeout if I'm using react-testing-library?

>All comments

This is best asked on our spectrum.chat. We try to limit the issue tracker to bugs and features.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chasen-bettinger picture chasen-bettinger  路  3Comments

julienw picture julienw  路  4Comments

jaredmeakin picture jaredmeakin  路  3Comments

albert-olive picture albert-olive  路  3Comments

alejandronanez picture alejandronanez  路  4Comments