How to use superagent-mock - 1 common examples

To help you get started, we’ve selected a few superagent-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datacamp / universal-rx-request / test / rxExtensions.js View on Github external
before(() => {
    mock = superagentMock(superagent, [
      {
        pattern: `${URL}(.*)`,
        fixtures: (match) => {
          switch (match[1]) {
            case 'get_movies':
              return { movies: MOVIES };
            default: throw new Error(404);
          }
        },
        get: (match, data) => ({ ok: true, code: 200, body: data }),
      },
    ]);
  });

superagent-mock

superagent plugin allowing to simulate HTTP calls by returning data fixtures based on the requested URL.

MIT
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis

Popular superagent-mock functions