How to use the superagent.__setMockError function in superagent

To help you get started, we’ve selected a few superagent 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 thelinmichael / spotify-web-api-node / __tests__ / http-manager.js View on Github external
test('Should process an error GET request with an error message', done => {
      superagent.__setMockError(
        new Error('There is a problem in your request')
      );

      var HttpManager = require('../src/http-manager');
      var request = Request.builder()
        .withHost('such.api.wow')
        .withPort(1337)
        .withScheme('http')
        .build();

      HttpManager.get(request, function(errorObject) {
        expect(errorObject).toBeInstanceOf(Error);
        expect(errorObject.message).toBe('There is a problem in your request');
        done();
      });
    });
github Sage / carbon / src / utils / helpers / poller / __spec__.js View on Github external
beforeEach(() => {
        Request.__setMockResponse({
          status() {
            return 500;
          },
          ok() {
            return false;
          },
          body: {
            message_type: 'error'
          }
        });

        Request.__setMockError({
          message: 'Unsuccessful HTTP response'
        });
      });
github Sage / carbon / src / utils / helpers / poller / __spec__.js View on Github external
afterEach(() => {
        Request.__setMockError(undefined);
      });
github Sage / carbon / src / components / table-ajax / __spec__.js View on Github external
beforeEach(() => {
      Request.__setMockResponse(response);
      Request.__setMockError(error);
      jest.useFakeTimers();
    });