-
Notifications
You must be signed in to change notification settings - Fork 126
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
Mocking UiRouter Classes with Jest #877
Comments
It depends what you're trying to test, but I've had success mocking just the For example: react/src/components/__tests__/UISref.test.tsx Lines 68 to 80 in 24a678d
|
@christopherthielen, thanks. this is helpful.
|
This issue has been automatically marked as stale because it has not had This does not mean that the issue is invalid. Valid issues may be reopened. Thank you for your contributions! |
This issue has been automatically closed. |
Hi! In our react app we are using UiRouter. When our team has tried to create unit tests, using jest and enzyme, for our components that are involved with the UiRouter we are getting several errors from the UiRouter. I was wondering if you could provide me with some information on how to appropriately mock the UiRouter in a unit test. The error our team is facing looks like the following:
TypeError: Cannot read property 'rules' of undefined
This is occurring in our router file where we are calling router.urlService.rules.initial( {state: "fakeState"} );
How can we mock the urlService class and the UrlRulesAPI implemented by the urlService class that is provided by the UiRouter so that our unit tests will pass successfully?
Note: we are currently already mocking the uirouter module as follows:
jest.mock('@uirouter/react');
Thank you for your help!
The text was updated successfully, but these errors were encountered: