Project

General

Profile

Bug #29717

Fix React test issues

Added by John Mitsch 6 months ago. Updated 17 days ago.

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

Description

Currently we are seeing issues with React tests not matching snapshots and other errors. For example:

[2020-05-07T11:20:36.675Z] + npm test

[2020-05-07T11:20:36.947Z] 

[2020-05-07T11:20:36.947Z] > katello@1.0.0 test /home/jenkins/workspace/katello-pr-test

[2020-05-07T11:20:36.947Z] > jest webpack

[2020-05-07T11:20:36.947Z] 

[2020-05-07T11:21:15.871Z] FAIL webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js (15.846s)

[2020-05-07T11:21:15.871Z]   ● Console

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]     console.warn node_modules/react/cjs/react.development.js:315

[2020-05-07T11:21:15.871Z]       Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]   ● subscription actions › updateQuantity › creates UPDATE_QUANTITY_REQUEST and then fails with 422

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]     expect(received).toEqual(expected) // deep equality

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]     - Expected

[2020-05-07T11:21:15.871Z]     + Received

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]     @@ -1,7 +1,14 @@

[2020-05-07T11:21:15.871Z]       Array [

[2020-05-07T11:21:15.871Z]         Object {

[2020-05-07T11:21:15.871Z]     +     "payload": Object {

[2020-05-07T11:21:15.871Z]     +       "messages": Array [],

[2020-05-07T11:21:15.871Z]     +       "result": [Error: Request failed with status code 404],

[2020-05-07T11:21:15.871Z]     +     },

[2020-05-07T11:21:15.871Z]     +     "type": "SUBSCRIPTIONS_QUANTITIES_FAILURE",

[2020-05-07T11:21:15.871Z]     +   },

[2020-05-07T11:21:15.871Z]     +   Object {

[2020-05-07T11:21:15.871Z]           "type": "UPDATE_QUANTITY_REQUEST",

[2020-05-07T11:21:15.871Z]         },

[2020-05-07T11:21:15.871Z]         Object {

[2020-05-07T11:21:15.871Z]           "payload": Object {

[2020-05-07T11:21:15.871Z]             "messages": Array [

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]       102 |         });

[2020-05-07T11:21:15.871Z]       103 |         await store.dispatch(updateQuantity(poolsUpdate));

[2020-05-07T11:21:15.871Z]     > 104 |         expect(store.getActions()).toEqual(updateQuantityFailureActions);

[2020-05-07T11:21:15.871Z]           |                                    ^

[2020-05-07T11:21:15.871Z]       105 |       },

[2020-05-07T11:21:15.871Z]       106 |     );

[2020-05-07T11:21:15.871Z]       107 |     it(

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z]       at _callee4$ (webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js:104:36)

[2020-05-07T11:21:15.871Z]       at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)

[2020-05-07T11:21:15.871Z]       at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:274:22)

[2020-05-07T11:21:15.871Z]       at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)

[2020-05-07T11:21:15.871Z]       at asyncGeneratorStep (webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js:21:103)

[2020-05-07T11:21:15.871Z]       at _next (webpack/scenes/Subscriptions/__tests__/SubscriptionsActions.test.js:23:194)

[2020-05-07T11:21:15.871Z] 

[2020-05-07T11:21:15.871Z] PASS webpack/scenes/RedHatRepositories/__tests__/RedHatRepositoriesPage.test.js (16.198s)

[2020-05-07T11:21:15.871Z]   ● Console

Associated revisions

Revision 68219a01 (diff)
Added by John Mitsch 6 months ago

Fixes #29717 - Fix React tests

Recently nock was introduced to testing. Importing `nock` from a place we also use `axios-mock-adapter` was causing issues as these mock network requests differently. Nock mocks from the nodejs level and axios-mock-adapter mocks the axios library. So initializing axios-mock-adapter and nock caused axios-mock-adapter to try to interecept the request before nock could.

We didn't see this locally because our dev env is on nodejs 10 and jenkins is on 12. I'm not sure why some runs passed and others have not.

Its likely a snapshot has to be re-recorded as well for the SubscriptionActions failure.

History

#1 Updated by The Foreman Bot 6 months ago

  • Target version deleted (Katello Backlog)
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/8703 added

#2 Updated by The Foreman Bot 6 months ago

  • Fixed in Releases added

#3 Updated by John Mitsch 6 months ago

  • Status changed from Ready For Testing to Closed

#4 Updated by James Jeffers 5 months ago

  • Target version set to Katello 3.16.0

#5 Updated by James Jeffers 5 months ago

  • Triaged changed from No to Yes

#6 Updated by Jonathon Turel 17 days ago

  • Fixed in Releases Katello 3.17.0 added
  • Fixed in Releases deleted ()
  • Pull request deleted (https://github.com/Katello/katello/pull/8703)

Also available in: Atom PDF