facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.24k stars 1.8k forks source link

Upgrade jest from 26 to 29 #4686

Closed necolas closed 1 month ago

necolas commented 1 month ago

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 commented 1 month ago

Are the Rust CI failures unrelated? Locally all the Rust tests pass, but rustup wouldn't let me downgrade to 1.36 on M1 Mac, so it modified Cargo.lock and changed the formatting of every crate file.

facebook-github-bot commented 1 month ago

@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

necolas commented 1 month ago

Closed by 89fe7bc14cf3049c06fbf82f70ade5272d40e17b