Closed
Description
Description
Hi, I'm having multiple errors when running my Jest tests after upgrading to v0.76.1
. Previously all of them were working fine in v0.75.4
.
All errors show the same "ReferenceError: _ii is not defined" message:
Test suite failed to run
ReferenceError: _ii is not defined
1 | jest.mock('react-native-keyboard-controller', () =>
> 2 | require('react-native-keyboard-controller/jest'),
| ^
3 | )
4 |
Setup files for Test:
__mocks__/react-native-keyboard-controller.js
jest.mock('react-native-keyboard-controller', () =>
require('react-native-keyboard-controller/jest'),
)
jest.config.js
module.exports = {
preset: 'react-native',
modulePaths: ['<rootDir>'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
setupFiles: [
'./__mocks__/react-native-keyboard-controller.js',
],
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
transformIgnorePatterns: [
'node_modules/(?!(jest-)?@?react-native|@react-native-community|@react-navigation|@pdftron|newrelic-react-native-agent)',
],
moduleNameMapper: {
'@storybook': '<rootDir>/__mocks__/storybook-react-native.js', // required to prevent storyboook import module error
'\\.svg': '<rootDir>/__mocks__/svgMock.js',
},
testTimeout: 10000,
}
metro.config.js
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const path = require('path')
const defaultConfig = getDefaultConfig(__dirname)
const { assetExts, sourceExts } = defaultConfig.resolver
/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {
transformer: {
experimentalImportSupport: false,
inlineRequires: true,
babelTransformerPath: require.resolve(
'react-native-svg-transformer/react-native',
),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg', 'mjs'],
},
}
const mergedConfig = mergeConfig(defaultConfig, config)
// Storybook v8
const withStorybook = require('@storybook/react-native/metro/withStorybook')
const storybookOptions = {
// Set to false to remove storybook specific options
// you can also use a env variable to set this
enabled: true,
// set this to 'true' to remove storybook from the bundle when "enabled" is set to 'false'
onDisabledRemoveStorybook: true,
// Path to your storybook config
configPath: path.resolve(__dirname, './.storybook'),
}
module.exports = withStorybook(mergedConfig, storybookOptions)
Steps to reproduce
- run the tests with the command
yarn jest --config jest.config.js
React Native Version
0.76.1
Stacktrace or Logs
Test suite failed to run
ReferenceError: _ii is not defined
1 | jest.mock('react-native-keyboard-controller', () =>
> 2 | require('react-native-keyboard-controller/jest'),
| ^
3 | )
4 |
at ii (node_modules/react-native/src/private/animated/NativeAnimatedHelper.js:100:38)
at createNativeOperations (node_modules/react-native/src/private/animated/NativeAnimatedHelper.js:99:68)
at Object.createNativeOperations (node_modules/react-native/src/private/animated/NativeAnimatedHelper.js:120:26)
at Object.<anonymous> (node_modules/react-native/Libraries/Animated/AnimatedEvent.js:16:1)
at Object.<anonymous> (node_modules/react-native/Libraries/Animated/AnimatedImplementation.js:23:1)
at Object.<anonymous> (node_modules/react-native/Libraries/Animated/Animated.js:21:1)
at Object.require [as Animated] (node_modules/react-native/index.js:215:12)
at Object.Animated (node_modules/react-native-keyboard-controller/jest/index.js:5:19)
at require (__mocks__/react-native-keyboard-controller.js:2:3)
at Object.<anonymous> (src/providers/BaseProviders.tsx:2:1)
at Object.<anonymous> (src/providers/index.tsx:1:1)
at Object.<anonymous> (src/test/providers.tsx:2:1)
at Object.<anonymous> (src/test/utils.ts:4:1)
Reproducer
This happens in my company project.