relay icon indicating copy to clipboard operation
relay copied to clipboard

Upgrade jest from 26 to 29

Open necolas opened this issue 2 months ago • 2 comments

This PR upgrades jest from 26 to 29 and makes related changes. The unit tests pass; the console.error warnings seem to be pre-existing. Included some of them below.

GraphQL fragments wrapped in a thunk

"this is legacy behavior and to be removed in the future"

    console.error
      Warning: RelayGraphQLTag: node `GraphQLTagTest1Query` unexpectedly wrapped in a function.

      67 |   if (typeof node === 'function') {
      68 |     node = (node(): ReaderFragment | ConcreteRequest);
    > 69 |     warning(
         |             ^
      70 |       false,
      71 |       'RelayGraphQLTag: node `%s` unexpectedly wrapped in a function.',
      72 |       node.kind === 'Fragment' ? node.name : node.operation.name,

      at printWarning (node_modules/fbjs/lib/warning.js:30:13)
      at Object.<anonymous>.warning (node_modules/fbjs/lib/warning.js:51:18)
      at getNode (packages/relay-runtime/query/GraphQLTag.js:69:32)
      at Object.getRequest (packages/relay-runtime/query/GraphQLTag.js:156:17)
      at Object.<anonymous> (packages/relay-runtime/query/__tests__/GraphQLTag-test.js:71:37)

Errors in the test-only warnings module.

There were other problematic patterns in this code that I fixed (nesting afterEach within tests; doesn't play well with jest.resetModules).

    console.error
      Unexpected Warning: expected warning #1

      60 |     } else {
      61 |       // log to console in case the error gets swallowed somewhere
    > 62 |       originalConsoleError(`Unexpected ${typenameCap}: ` + message);
         |       ^
      63 |       throw new Error(`${typenameCap}: ` + message);
      64 |     }
      65 |   }

      at handleMessage (packages/relay-test-utils-internal/consoleErrorsAndWarnings.js:62:7)
      at packages/relay-test-utils-internal/warnings.js:29:11
      at packages/relay-test-utils-internal/__tests__/warnings-test.js:84:36
      at Object.expectMessageMany (packages/relay-test-utils-internal/consoleErrorsAndWarnings.js:116:18)
      at Object.expectToWarnMany (packages/relay-test-utils-internal/warnings.js:70:25)
      at packages/relay-test-utils-internal/__tests__/warnings-test.js:83:30
      at Object.<anonymous> (node_modules/expect/build/toThrowMatchers.js:74:11)
      at Object.throwingMatcher [as toThrowError] (node_modules/expect/build/index.js:320:21)
      at Object.<anonymous> (packages/relay-test-utils-internal/__tests__/warnings-test.js:87:8)

Other

   Warning: RelayResponseNormalizer: Payload did not contain a value for field `text: text`. Check that you are parsing with the same query that was used to fetch the payload.

      513 |           // to be present
      514 |           if (__DEV__) {
    > 515 |             warning(
          |                     ^
      516 |               false,
      517 |               'RelayResponseNormalizer: Payload did not contain a value ' +
      518 |                 'for field `%s: %s`. Check that you are parsing with the same ' +

necolas avatar Apr 24 '24 23:04 necolas