I'm submitting a ... (check one with "x"):
Bug report
Current behavior:
Unable to mock the plugin as part of unit testing.
Tried to mock the plugin as following: jest.mock('react-native-launch-navigator', () => 'LaunchNavigator');
Getting exception on running npm test:
● Test suite failed to run
Invariant Violation: Native module cannot be null.
23 | import Sound from 'react-native-sound';
> 24 | import LaunchNavigator from 'react-native-launch-navigator';
| ^
at invariant (node_modules/invariant/invariant.js:40:15)
at new NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:36:27)
at RNLogger._addListeners (node_modules/react-native-launch-navigator/RNLogger.js:11:33)
at new RNLogger (node_modules/react-native-launch-navigator/RNLogger.js:48:10)
at Object.<anonymous> (node_modules/react-native-launch-navigator/index.js:24:14)
at Object.<anonymous> (src/utils/CommonFunctions.js:24:58)
Mocking of plugin is not working
Expected behavior:
Unit testing with Jest should work
Mocking of the plugin should be successfully performed.
Steps to reproduce:
npm test
with some code containing import to react-native-launch-navigator
Environment information
- React Native version
- Other React Native modules/components/tools
- "dependencies": {
"jetifier": "1.6.4",
"@bugfender/rn-bugfender": "1.0.0",
"@ptomasroos/react-native-multi-slider": "1.0.0",
"@react-native-community/async-storage": "1.3.3",
"@react-native-community/netinfo": "3.2.1",
"axios": "0.19.0",
"codacy-coverage": "^3.4.0",
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.12.1",
"enzyme-to-json": "3.3.5",
"i18n-js": "3.2.1",
"native-base": "2.12.1",
"prop-types": "15.7.2",
"react": "16.8.3",
"react-dom": "16.8.6",
"react-native": "0.59.10",
"react-native-background-geolocation": "3.2.2",
"react-native-camera-kit": "8.0.0",
"react-native-device-info": "2.1.2",
"react-native-firebase": "5.5.5",
"react-native-gallery-swiper": "1.22.2",
"react-native-gesture-handler": "git+https://github.com/ShaMan123/react-native-gesture-handler.git",
"react-native-indicator": "1.0.0",
"react-native-launch-navigator": "1.0.5",
"react-native-linear-gradient": "2.5.4",
"react-native-modal": "11.0.1",
"react-native-permissions": "2.0.0-alpha.1",
"react-native-sound": "0.11.0",
"react-native-svg": "9.6.2",
"react-native-svg-animated-linear-gradient": "0.3.2",
"react-native-svg-uri": "1.2.3",
"react-native-vector-icons": "6.5.0",
"react-native-webview": "5.11.0",
"react-native-wheel-picker-extended": "1.2.0",
"react-navigation": "3.6.1",
"react-redux": "6.0.1",
"redux": "4.0.1"
},
"devDependencies": {
"@babel/core": "7.5.0",
"@babel/runtime": "7.5.0",
"@types/jest": "24.0.20",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.9.0",
"eslint": "6.6.0",
"eslint-config-airbnb": "18.0.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.16.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.53.1",
"prettier-eslint": "8.8.2",
"react-native-version": "3.0.0",
"react-test-renderer": "16.11.0",
"ts-jest": "24.1.0",
"typescript": "3.6.4"
},
"jest": {
"preset": "react-native",
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"globals": {
"window": {}
},
"transform": {
"^.+\.ts?$": "ts-jest",
"^.+\.tsx?$": "ts-jest",
"^.+\.js$": "./node_modules/react-native/jest/preprocessor.js"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"moduleNameMapper": {
"^.+\.(css|less|scss)$": "identity-obj-proxy"
},
"transformIgnorePatterns": [],
"setupFiles": [
"./jestSetup.js"
]
}
}
- Dev machine OS and version, e.g.
- OSX Mojave 10.14.5
- Windows 10
Console output
console output
// Paste any relevant JS/native console output here
I'm submitting a ... (check one with "x"):
Bug report
Current behavior:
Unable to mock the plugin as part of unit testing.
Tried to mock the plugin as following: jest.mock('react-native-launch-navigator', () => 'LaunchNavigator');
Getting exception on running npm test:
● Test suite failed to run
Mocking of plugin is not working
Expected behavior:
Unit testing with Jest should work
Mocking of the plugin should be successfully performed.
Steps to reproduce:
npm test
with some code containing import to react-native-launch-navigator
Environment information
"jetifier": "1.6.4",
"@bugfender/rn-bugfender": "1.0.0",
"@ptomasroos/react-native-multi-slider": "1.0.0",
"@react-native-community/async-storage": "1.3.3",
"@react-native-community/netinfo": "3.2.1",
"axios": "0.19.0",
"codacy-coverage": "^3.4.0",
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.12.1",
"enzyme-to-json": "3.3.5",
"i18n-js": "3.2.1",
"native-base": "2.12.1",
"prop-types": "15.7.2",
"react": "16.8.3",
"react-dom": "16.8.6",
"react-native": "0.59.10",
"react-native-background-geolocation": "3.2.2",
"react-native-camera-kit": "8.0.0",
"react-native-device-info": "2.1.2",
"react-native-firebase": "5.5.5",
"react-native-gallery-swiper": "1.22.2",
"react-native-gesture-handler": "git+https://github.com/ShaMan123/react-native-gesture-handler.git",
"react-native-indicator": "1.0.0",
"react-native-launch-navigator": "1.0.5",
"react-native-linear-gradient": "2.5.4",
"react-native-modal": "11.0.1",
"react-native-permissions": "2.0.0-alpha.1",
"react-native-sound": "0.11.0",
"react-native-svg": "9.6.2",
"react-native-svg-animated-linear-gradient": "0.3.2",
"react-native-svg-uri": "1.2.3",
"react-native-vector-icons": "6.5.0",
"react-native-webview": "5.11.0",
"react-native-wheel-picker-extended": "1.2.0",
"react-navigation": "3.6.1",
"react-redux": "6.0.1",
"redux": "4.0.1"
},
"devDependencies": {
"@babel/core": "7.5.0",
"@babel/runtime": "7.5.0",
"@types/jest": "24.0.20",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.9.0",
"eslint": "6.6.0",
"eslint-config-airbnb": "18.0.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.16.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.53.1",
"prettier-eslint": "8.8.2",
"react-native-version": "3.0.0",
"react-test-renderer": "16.11.0",
"ts-jest": "24.1.0",
"typescript": "3.6.4"
},
"jest": {
"preset": "react-native",
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"globals": {
"window": {}
},
"transform": {
"^.+\.ts?$": "ts-jest",
"^.+\.tsx?$": "ts-jest",
"^.+\.js$": "./node_modules/react-native/jest/preprocessor.js"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"moduleNameMapper": {
"^.+\.(css|less|scss)$": "identity-obj-proxy"
},
"transformIgnorePatterns": [],
"setupFiles": [
"./jestSetup.js"
]
}
}
sw_verswinverConsole output
console output