Bug #35165
closedJS test improvements - assertNockRequest & nock.cleanAll()
Description
Some JS test improvements needed:
1. In global_test.setup.js we call
afterEach(() => {
nock.restore();
});
restore() restores the HTTP interceptor to the normal unmocked behaviour, which is not desired or needed after each test. Instead we should change it to
afterEach(() => {
nock.cleanAll();
});
which clears all Nock scopes, and as a side bonus allows us to remove `nock.cleanAll()` from individual test files.
2. In NockWrapper.js there's a `setInterval` which calls the jest `done()` function. The problem is that `setInterval` does not call its passed function until after `delay` milliseconds - see https://developer.mozilla.org/en-US/docs/Web/API/setInterval
So the minimum time before calling jest done() will be 500 milliseconds. This means we are wasting countless seconds on our test runs.
Jest done() should also be checked and called before the first interval.
Updated by The Foreman Bot over 2 years ago
- Status changed from New to Ready For Testing
- Assignee set to Jeremy Lenz
- Pull request https://github.com/Katello/katello/pull/10187 added
Updated by The Foreman Bot over 2 years ago
- Fixed in Releases Katello 4.5.1 added
Updated by Jeremy Lenz over 2 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|8eac390cac53bd7f99bff7165fc472578dcee1bf.
Updated by Lucy Fu over 2 years ago
- Target version set to Katello 4.6.0
- Triaged changed from No to Yes