Skip to content

Tests are failing after upgrading react native from 0.69.6 to 0.71.0 #36440

Closed
@arthedza

Description

@arthedza

Description

Hello! After the update I started getting the following errors:

TypeError: Cannot redefine property: performance

      at Object.<anonymous> (node_modules/react-native/jest/setup.js:404:20)
TypeError: Cannot redefine property: window

      at Object.<anonymous> (node_modules/react-native/jest/setup.js:405:15)

Everything works fine if I comment out the appropriate lines in file node_modules/react-native/jest/setup.js:

...
global.__DEV__ = true;

// global.performance = {
//   now: jest.fn(Date.now),
// };

global.regeneratorRuntime = jest.requireActual('regenerator-runtime/runtime');
// global.window = global;

global.requestAnimationFrame = function (callback) {
  return setTimeout(callback, 0);
};
...

React Native Version

0.71.0

Output of npx react-native info

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Apple M1
    Memory: 16.64 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.7.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 9.5.0 - /usr/local/bin/npm
    Watchman: 2023.02.27.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.12.0 - /Users/user/.rvm/gems/ruby-2.7.6/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 28, 29, 30, 31, 32, 33
      Build Tools: 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 33.0.0
      System Images: android-29 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9619390
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.0 => 0.71.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Upgrade the RN version

Snack, code example, screenshot, or link to a repository

...
global.__DEV__ = true;

// global.performance = {
//   now: jest.fn(Date.now),
// };

global.regeneratorRuntime = jest.requireActual('regenerator-runtime/runtime');
// global.window = global;

global.requestAnimationFrame = function (callback) {
  return setTimeout(callback, 0);
};
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions