-
-
Notifications
You must be signed in to change notification settings - Fork 517
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
Angular MSW (Jest) #273
Comments
Hey, @timdeschryver! Thanks for reporting this. I confirm that there's an issue in the I'll tackle this on the NRI side and let you know once I have more details. |
I have tried the code and the handler is called but the response never arrived |
I've found the root cause of the issue and tackling this at the moment. Will issue a pull request soon. |
The issue is fixed in |
Wow, that was quick - thanks @kettanaito ! It's time to introduce MSW to the Angular community 🙌 |
@timdeschryver, glad to help. I'm super excited for Angular community to adopt MSW! Looking forward to hear more interesting use-cases. |
I think that angular example should be created. What do you think ? |
Tim already wrote a blog post on the topic: https://timdeschryver.dev/blog/using-msw-in-an-angular-project |
Okok I see, but maybe we could add angular project example here in this way with new updates we are pretty sure that they will work on angular and react. On the CI there is a step that run examples with new version of MSW |
Definitely agree. We should have an official Angular example 👍 You can use the React REST API example as a reference. |
Feel free to assign that to me if you'd like. |
@kettanaito I just verified that it works with |
@timdeschryver so happy to hear that! |
Hi @timdeschryver |
First of all, thank you for writing this library.
It's been a joy to use it on a demo project.
Environment
Request handlers
Actual request
Current behavior
The requests reaches the MSW handler, but Angular doesn't receive the response.
Expected behavior
I would expect that the Angular HTTP client handles the request/response correctly.
This only happens with Angular + Jest, with Jasmine/Karma Angular does receive the response.
Observations
What I see is that Angular uses
addEventListener
to receive XHR responses.When I rewrite this line, by just using the
onload
function, the response gets handled correctly.I have no idea why, and I'm not sure where to look.
I was wondering if you have seen this behavior before with other libraries.
The Angular source code can be found here
An older reproduction of this can be found here
To reproduce:
yarn
yarn test:jest
to run the jest testyarn test
to run the jasmine testThe text was updated successfully, but these errors were encountered: