-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
BugIssue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
π Bug Report
When requiring react-native in node context (e.g. jest) module warnOnce cannot be found.
β Test suite failed to run
Cannot find module 'warnOnce' from 'react-native-implementation.js'
To Reproduce
TestFile.js
import { PixelRatio } from 'react-native'
export default class TestFile {
}
TestFile.test.js
import TestFile from './TestFile'
test('test', () => {
...
})
Expected Behavior
warnOnce should be found and loaded just like invariant.
Workaround
As a workaround I'm mocking react-native dependency with jest.doMock('react-native', () => reactNativeMock))
Environment
info
React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
Memory: 3.06 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
Yarn: 1.13.0 - ~/.nvm/versions/node/v8.10.0/bin/yarn
npm: 6.8.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 21.1.2, 23.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3
System Images: android-19 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.0
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-rename: 2.4.0
InfiniteRandomVariable, fraserscottmorrison, Elf2707, janhesters, matei-radu and 29 moremanuquentin, Not-your-average-coder and relign
Metadata
Metadata
Assignees
Labels
BugIssue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.This issue can be reproduced in Snack or an attached project.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.