Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jest testing :: Test failed and error routing to \react-native-vector-icons

Hi i have been trying to run 'npm test' faced a couple of issues like this with native-base but resolved by placing 'native-base-shoutem-theme|||tcomb-form-native' in transformIgnorePatterns key in my Package.json file.

but haven't found a solution with react-native-vector-icons as shown below

    [email protected] test D:\ReactWorkSpace\myapp
jest
PASS tests\index.ios.js
FAIL tests\index.android.js
● Test suite failed to run
D:\ReactWorkSpace\myapp\node_modules\native-base\node_modules\react-native-vector-icons\Ionicons.js:6
import createIconSet from './lib/create-icon-set';
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (node_modules/native-base/dist/src/basic/IconNB.js:5:15)
at Object.<anonymous> (node_modules/native-base/dist/src/index.js:16:13)
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.189s, estimated 8s
Ran all test suites.
npm ERR! Test failed. See above for more details

my package.json file is

{
"name": "myapp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"js-base64": "^2.1.9",
"moment": "^2.18.1",
"native-base": "^2.2.1",
"react": "16.0.0-alpha.12",
"react-native": "0.46.0",
"react-native-animatable": "^1.2.2",
"react-native-button": "^2.0.0",
"react-native-drawer": "^2.3.0",
"react-native-linear-gradient": "^2.2.0",
"react-native-material-design": "^0.3.7",
"react-native-material-kit": "^0.4.1",
"react-native-material-ui": "^1.12.0",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "^1.0.0-beta.11",
"react-toolbox": "^2.0.0-beta.12",
"render-if": "^0.1.1"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.1.0",
"jest": "^20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
  "node_modules/(?!react-native|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
]
}
}
like image 956
Md.Nawaz Avatar asked Aug 31 '17 12:08

Md.Nawaz


1 Answers

Add this to your package.json. It solves your problem :)

"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
        "/node_modules/(?!native-base)/"
    ],

    ...
}
like image 116
Burhan Yılmaz Avatar answered Nov 01 '22 17:11

Burhan Yılmaz