Skip to content

Allow more customization of network mocking urls #53

@danwenzel

Description

@danwenzel

nock has several customization options that would be nice to implement in ember-cli-fastboot-testing's network mocking. Just to mention a few:

  • Setting of the hostname - Currently, we are limited to using the same hostname as the test runner. Oftentimes we have a separate api host that we'd like to override.
  • Customizing the path - Currently, we can only use exact path matches - it would be great to be able to use RegEx or the includes option.
  • Customizing the query string - Similar to above, it would be really helpful to explicitly specify the query string, use regex, or use nock's .query(true) option to ignore the query string altogether. Otherwise, it's only a match if the query string is appended to the url with the exact full string.

We also have this issue: https://github.com/embermap/ember-cli-fastboot-testing/issues

It seems like we either need a way to use nock's syntax when creating these mocks, or expand the API to allow several different customization options. Maybe something like:

await mockServer.get('/api/posts/1', { <body>}, { <options> } )

(we'd have to move the status code into an option, and maybe deprecate the string as a 3rd param)

I'd be happy to work on a PR for this once we land on the approach.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions