Test times out unexpectedly, despite expected behavior otherwise
See original GitHub issueHi there, @clavery63 and I have noticed some behavior that we believe is a bug, resulting in tests timing out when they should complete successfully.
I’ve reproduced here https://codesandbox.io/s/suspicious-ardinghelli-0yt2n
import { cold } from "jest-marbles";
describe("timeout error", () => {
test("times out without completing observable", done => {
const fakeActions = cold("t|", { t: true });
fakeActions.subscribe({
next: value => {
console.log("value received:", value);
expect(value).toEqual(true);
},
complete: () => {
console.log("observable complete");
done();
}
});
});
});
Based on the way the logs appear, and our understanding of the tools involved, we’d expect the test to pass, but instead it times out.
If this is expected behavior, please let us know if you have thoughts on how to go about testing this sort of thing effectively. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Testing-library: avoid these mistakes in async tests
Sometimes, tests start to unexpectedly fail even if no changes were made to the business logic. It may happen after e.g. you updated...
Read more >For async tests and hooks, ensure "done()" is called
Once rejected done is never called and mocha reports time out. I solved this by writing a .catch block and chaining it with...
Read more >Test Anxiety (for Teens) - Nemours KidsHealth
Test anxiety is not the same as doing poorly on a certain test because your mind is on something else.
Read more >Cypress and Flaky Tests: How to Handle Timeout Errors
One such default behavior involves automatically waiting for four seconds (ideally to allow your application to finish whatever operation it may ...
Read more >Fix program errors and improve code - Visual Studio (Windows)
In this article, find out how Visual Studio can help you find problems in your code using build output, code analysis, debugging tools,...
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
Please use
toSatisfyOnFlush
, available since 2.5.0.Let me know if that helps.
Yeah, it seems that testing side effects is currently a bit problematic. I have a few things in mind (such as adding
toHaveSideEffect
matcher), will see what can be done.There is a workaround for you until it’s done though. You can pipe to the tested stream and
tap
your assert: