facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

[Feature]: Fake Timers #34

Open daniel-nagy opened 5 years ago

daniel-nagy commented 5 years ago

It looks like fake timers have been purposefully turned off. Would it be possible to implement fake timers?

aaronabramov commented 5 years ago

there was an issue with a shared state in the early version of this runner (all tests shared the same window) and using fake timers was really unsafe, but i think current implementation should allow implementing fake timers. i have not looked into it yet!

pull request would be appreciated 🙂 here's where they're initialized (or disabled in this case) https://github.com/facebook-atom/jest-electron-runner/blob/master/packages/electron/src/Environment.js#L24-L30

daniel-nagy commented 5 years ago

Unsafe as in Spectre and Meltdown unsafe?

aaronabramov commented 5 years ago

not that unsafe 😅 but potentially can leak state from one test to another. I think right now we're running every test in a separate electron window and disposing it after the test is done, so it should be easy to implement the same support as the main jest runner

steel commented 4 years ago

I created a PR here: https://github.com/facebook-atom/jest-electron-runner/pull/67

witthong commented 3 years ago

Would it be possible to implement fake timers?