grug / data-mocks

Library to mock local data requests using Fetch or XHR
MIT License
63 stars 12 forks source link

Support wildcard urls #43

Closed simondel closed 5 years ago

simondel commented 5 years ago

Is your feature request related to a problem? Please describe. I want to have a fallback for all URL's to they return a statuscode 404 unless they are specifiek in the scenario.

Describe the solution you'd like An example on how to do this.

Describe alternatives you've considered I've tried a wildcard regex:

const scenarios: Scenarios = {
    default: [
      {
        url: /(.*?)/,
        method: 'GET',
        response: {},
        responseCode: 404
      }
    ]
  }
injectMocks(scenarios);
simondel commented 5 years ago

Wildcard urls work, I was just being an idiot in my code because I didn't catch the 404 not found error.. 🙈