Skip to content
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 rest-angular example #28

Merged
merged 4 commits into from
Aug 11, 2020
Merged

Conversation

timdeschryver
Copy link
Member

@timdeschryver timdeschryver commented Aug 8, 2020

As mentioned before, I wanted to add an angular example to this repo 🙂

It includes:

  • the same example as the rest-react example
  • unit tests with Jest and the Angular Testing Library
  • cypress tests with Cypress Testing Library

I tried to copy the setup of the react example.
If I missed something or did something wrong feel free to correct me.

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @timdeschryver!

Thank you so much for this awesome example! If you don't mind, I've added a few comments to align it better with the goal we have towards examples. Let me know if those suggestions can be addressed, or need any kind of discussion.

Looking forward to hearing from you!

@timdeschryver
Copy link
Member Author

Thanks for the review @kettanaito
I addressed all the feedback in the latest commit.
Can I do something for the failing build?

@timdeschryver
Copy link
Member Author

timdeschryver commented Aug 9, 2020

I also run into the following problem while trying to run the angular example.

ERROR in ../../node_modules/msw/lib/types/context/cookie.d.ts:1:8 - error TS1192: Module '"C:/Users/tdeschryver/dev/clones/examples/node_modules/@types/cookie/index"' has no default export.

1 import cookieUtils from 'cookie';         ~~~~~~~~~~~

To fix it I had to change cookie.d.ts:

- import cookieUtils from 'cookie';
+ import * as cookieUtils from 'cookie';

EDIT:

Seems like this was fixed in mswjs/msw#322
Msw v0.20.1 is used in the example, it's resolved after the update to v0.20.3

@kettanaito
Copy link
Member

@timdeschryver, thanks for addressing the comments!

Regarding the cookie.d.ts issue, it seems you have an old version of msw installed locally. Could you ensure that you have 0.20.3 locally?

$ npm ls msw

@timdeschryver
Copy link
Member Author

@kettanaito I came to the same conclusion 😁
See the EDIT in my comment, it's indeed fixed in v0.20.3.
Sorry for the confusion.

@kettanaito
Copy link
Member

That being said, I'm not sure why it reports a corrupted Cypress download on CI. I'll try to build and test this example locally and would also kindly ask you to do so.

@timdeschryver
Copy link
Member Author

I've found an issue that mentioned the error we experienced if multiple versions of cypress were installed.
I updated the angular example to match to other versions but the error still occured.
That's why I upgraded to the latest version of cypress.

The storybook tests were failing because I've installed jest v26.
To fix it, I also upgraded storybook.

Let me know if this is alright, or if I have to downgrade jest to v25.
If you want I can also squash my commits into one.

@kettanaito
Copy link
Member

It looks perfectly fine! Thank you for the work on this.

@kettanaito
Copy link
Member

Yes, if you may, I'd kindly ask you to squash those "cypress" version commits into one that fixes the dependencies issue. Would this be possible?

@timdeschryver
Copy link
Member Author

Will do, I'll try to push these changes in later today.

@timdeschryver
Copy link
Member Author

there we go 😁

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you once more for preparing this, @timdeschryver!

I'm so excited to have an official Angular usage example. You rock!

@kettanaito
Copy link
Member

Welcome to contributors 🎉

@kettanaito kettanaito merged commit fa0eb64 into mswjs:master Aug 11, 2020
@timdeschryver timdeschryver deleted the pr/rest-angular branch August 11, 2020 08:24
@timdeschryver
Copy link
Member Author

Thank you @kettanaito
Feel free to ping me if someone is having troubles with Angular + MSW, I'm happy to help out wherever I can because MSW is super useful!

@kettanaito
Copy link
Member

Will do, Tim! I'm extremely happy to have you as a contributor. Looking forward to the feedback from Angular developers on this amazing integration.

@kettanaito
Copy link
Member

This example is also live on our Examples page on the website 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants