Support for useFakeTimers('modern')
See original GitHub issueI would like to be able to use this lib to mock out dynamo but am reaching a blocking issue when using jest v26 features, namely useFakeTimers('modern')
.
Using the preset, any test that calls into the local db results in the following error:
TypeError: Cannot read property 'useFakeTimers' of undefined
...
jest.useFakeTimers(`modern`);
^
I attempted to patch in the calls to useFakeTimers
to accept the "modern"
type argument, but that did not change the outcome. Any test that does not include the call to the db works as expected. I am fairly new to using jest so I’m not counting out user error, but it seems like something is off only when this lib is involved in the test. Worth noting, this will become the default in the next major version of jest.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Jest 26: Tick Tock
In Jest 26, this new implementation will remain opt-in and can be activated by calling jest.useFakeTimers('modern') or by passing modern to the ...
Read more >Problems with using useFakeTimers('modern') in a create ...
I was trying to test a component that used Lodash's debounce function without having to slow the tests down by waiting for the...
Read more >"Modern" fake-timer implementation doesn't work with ... - GitHub
Testing async code with Promises, as described in this Jest doc, doesn't seem to work with jest.useFakeTimers('modern'); (from #7776; ...
Read more >How to use jest.useFakeTimers('modern') and jest ...
useFakeTimers ('modern') and jest.setSystemTime() but I don't know why it breaks my test. Does anyone know how to work with these two helpers ......
Read more >Jest fake timers with promises - Stack Overflow
useFakeTimers ('modern') works with Date but not with Promises since await flushPromises() never resolves. The best solution I found was to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure. Here is basically the testing I was able to do to see where tests failed to run. It did not matter where I set jest timers to
'modern'
.timers: 'modern'
in config,beforeAll
,beforeEach
, in the test body, all failed similarly.Release as
v3.2.2