Sha256: 453aea02110a603f8ba1703a531807ad932a06bb2f79f8cf8f02b2affec9cde2

Contents?: true

Size: 861 Bytes

Versions: 10

Compression:

Stored size: 861 Bytes

Contents

import nock from 'nock';

// Using the library 'nock' as it matches actual network requests rather than mock another
// library. This is helpful when the request is not coming from Katello. For example, axios
// called within Katello can be mocked with axios-mock-adapter or similar, but a http request
// made by axios that is coming from Foreman cannot be mocked by axios-mock-adapter or a
// jest mock within Katello. So to do this, we can mock the request a level deeper within
// nodejs by using nock.
export const nockInstance = nock('http://localhost');

// Calling .done() with nock asserts that the request was fufilled. We use a timeout to ensure
// that the component has set up and made the request before the assertion is made.
export const assertNockRequest = (scope, timeout = 10000) => {
  setTimeout(() => {
    scope.done();
  }, timeout);
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-3.16.2 webpack/test-utils/nockWrapper.js
katello-3.16.1.2 webpack/test-utils/nockWrapper.js
katello-3.16.1.1 webpack/test-utils/nockWrapper.js
katello-3.16.1 webpack/test-utils/nockWrapper.js
katello-3.16.0 webpack/test-utils/nockWrapper.js
katello-3.16.0.rc5.1 webpack/test-utils/nockWrapper.js
katello-3.16.0.rc5 webpack/test-utils/nockWrapper.js
katello-3.16.0.rc4.1 webpack/test-utils/nockWrapper.js
katello-3.16.0.rc4 webpack/test-utils/nockWrapper.js
katello-3.16.0.rc3.1 webpack/test-utils/nockWrapper.js