rxjs
rxjs copied to clipboard
chore(test): use fakeTimers with setTimeout in buffer, skipUntil and window
Description:
After checking out the rxjs repo and running the unit tests, I noticed these 3 tests were always failing. (I'm running Windows 10 with Node 20)
The issue is probably that setTimeout does not necessarily execute at the specified delay. I tried to reproduce the test in StackBlitz and I had the exact same issue when using timeouts so close to each other.
The PR updates these tests to use fake timers to make sure the tests work as expected.
I had the same issue when running the tests on Windows 10 [email protected]. It's very annoying to contribute when there are unrelated failing tests.
I came across this interesting stackoverflow question: https://stackoverflow.com/questions/65177373/odd-behavior-with-setinterval-in-node-js-windows-only-works-in-linux that seems to explain the issue.
fakeTimers
seems to be the way to go if we don't want to slow down the tests to be consistent in different platforms.