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

Raise Errors for Missing Routes #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

FinnLawrence
Copy link

Overview

We are using cypress-autorecord to mock out our backend APIs in several React-only front-end apps deployed as static bundles that perform cross-origin API requests.

We want to fail a test if code calls one of our API endpoints that we don't expect (i.e. it matches the intercept pattern but it's not in the mock).

Solution

  • Add a raiseMissingRouteErrors configuration setting.
  • When this is enabled, raise an error if:
    • We have an existing mock for the test.
    • This mock doesn't include the route we're fetching.
    • The route we're fetching matches the intercept pattern.
  • Skip the above if the isTestForceRecord or recordTests flags are being used. Lets you update mocks easily by turning these on to add new routes if required.

@Nanciee let me know if you'd like to merge this in or whether we should look to maintain our own fork. I am also interested in adding an option to group mocks in folders to mirror the file structure of the tests, looks like this one was never merged but can do a version of this and open a subsequent PR if you'd appreciate more contributions 😎

@FinnLawrence FinnLawrence changed the title Raise Errors for Missing Route Mocks Raise Errors for Missing Routes Apr 21, 2023
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.

1 participant