-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to flush pending message queue #51
Comments
Hi @Coteh ! Thanks for the feedback, that's a good point! I'm totally up for implementing something like that, but I'm afraid that the best solution would be a breaking change:
Would that fix your problem? |
I believe this would fix my problem yes, and I’d love to take a crack at it. :) You can assign the issue to me and hopefully I’ll have some time on the weekend to work on it.
On Jan 20, 2021, at 12:29 PM, Romain Bertrand <notifications@github.com<mailto:notifications@github.com>> wrote:
Hi @Coteh<https://github.com/Coteh> !
Thanks for the feedback, that's a good point!
I'm totally up for implementing something like that, but I'm afraid that the best solution would be a breaking change:
* .toReceiveMesage should be updated to not stop at the next message, but instead wait until it finds a message matching the expected value
* we should add a toReceiveMessageNext matcher that works like the existing toReceiveMessage
Would that fix your problem?
If so, is that something you'd be interested in working on?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#51 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAY74PQT5ZM2Q6FLLHC7JXLS24HFXANCNFSM4VHWUAOQ>.
|
Thanks @Coteh ! |
Hey just wondering what you think should happen if From what I've read of the codebase so far, it doesn't seem to me that would be any timing issues with messages being received much later than they're supposed to, but just want to confirm with you if this is the case. Thanks. |
Yup, that sounds good 👍 What would also be useful when we hit the timeout, would be to show all the messages we received since the Maybe something like “Expected message |
I am currently utilizing this library to mock communication between my frontend app and an IRC gateway called webircgateway for my unit tests, and I wasn't able to find a function that can clear out the pending message queue within a test. I am testing whether my app can send out a message, and I currently have to copy and paste
await server.nextMessage
so that I can discard the IRC initial communication messages (PASS, NICK, and USER) which I don't care about so that I can then calltoReceiveMessage
andtoHaveReceivedMessages
on thePRIVMSG
message, which I do care about.I attempted to make my own makeshift flush function:
However, it does not seem to work because once I clear out the queue (which happens when we cannot get any more messages and the 2s timeout returns
null
) any message I send through the WebSocket is reported by the mock server asundefined
:I have decided to work around this for the time being by copy and pasting
await server.nextMessage
like I mentioned earlier in order to clear out the queue, but I would like to know why this is happening if possible. Also, let me know if flushing the pending message queue is something that can benefit this project, thanks.The text was updated successfully, but these errors were encountered: