Project

General

Profile

Actions

Bug #35165

closed

JS test improvements - assertNockRequest & nock.cleanAll()

Added by Jeremy Lenz over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tests
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

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.

Actions #1

Updated by The Foreman Bot over 1 year ago

  • Status changed from New to Ready For Testing
  • Assignee set to Jeremy Lenz
  • Pull request https://github.com/Katello/katello/pull/10187 added
Actions #2

Updated by The Foreman Bot over 1 year ago

  • Fixed in Releases Katello 4.5.1 added
Actions #3

Updated by Jeremy Lenz over 1 year ago

  • Status changed from Ready For Testing to Closed
Actions #4

Updated by Lucy Fu over 1 year ago

  • Target version set to Katello 4.6.0
  • Triaged changed from No to Yes
Actions

Also available in: Atom PDF