Open jduss4 opened 3 months ago
I created 3 scenarios, 2 of which cause a DIFFERENT test to fail. It would appear the nock discrepancy is somehow related to how the async / promise stuff is expressed, although I am unclear why it is happening in this case and NOT in other cases. If I comment out the test which it reports is failing, however, example 3 passes as expected.
When no tests are commented out:
await
nock(process.env.UAA_API_URL).get(/Users/).reply(200, mockUaaUsers);
const result = await getOrgPage('orgGuid');
expect(result).toBeDefined();
nock(process.env.UAA_API_URL).get(/Users/).reply(200, mockUaaUsers);
expect(getOrgPage('orgGuid')).resolves.toBeDefined();
Result for "getOrgPage > if the CF requests succeed > returns the expected controller result"
Error: something went wrong: Nock: No match for request
nock(process.env.UAA_API_URL).get(/Users/).reply(500);
expect(async () => {
await getOrgPage('orgGuid');
}).rejects.toThrow(new Error('something went wrong with the request'));
Result for "getOrgPage > if the CF requests succeed > returns the expected controller result"
Error: something went wrong: Nock: No match for request
I do not understand what the difficulty is here. But sure enough, even though UAA is no longer in the picture, and even though we have a successful test with the EXACT SAME SECOND REQUEST, something about making it respond as 500 instead of 200 throws nock off its game.
This test was removed when the UAA API /Users endpoint was added, as nock was reluctant to allow the second
/roles
CF request to match. See previous discussion and code here: https://github.com/cloud-gov/cg-ui/pull/254/files#r1626583204Acceptance Criteria
getOrgPage
when one of the second waves of requests fails