Nativebase: Unexpected token import in Shoutem dependency

Created on 4 Apr 2017  路  12Comments  路  Source: GeekyAnts/NativeBase

react-native, react and native-base version

react - 15.4.2
react-native - 0.42.3
native-base - 2.1.0
jest - 19.0.2

Expected behaviour

The Jest test suite is expected to run & tests pass

Actual behaviour

SyntaxError: Unexpected token import when importing connectStyle in the @shoutem dependency.

screen shot 2017-04-04 at 8 55 21 am

Is the bug present in both ios and android or in any one of them?

This has only been tested in iOS.

bug

Most helpful comment

just modify jest config package.json

Works for me. Seems like it's a common problem

  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|@shoutem/theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
    ],
    "setupFiles": [
      "./test/setup.js"
    ]
  }

All 12 comments

just modify jest config package.json

Works for me. Seems like it's a common problem

  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|@shoutem/theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
    ],
    "setupFiles": [
      "./test/setup.js"
    ]
  }

I am still getting same error even after modifying jest config in package.json. Any ideas?

SOLVED: Was having multiple entries for different libraries in transformIgnorePatterns and thats why it didn't work properly. Putting all in one solved the issue.

@matejstrasek can you explain what you did ?

@sidd607 sorry for late response. If you still haven't solve it: I was putting additional elements into transformIgnorePatterns for each library and didn't work. Using all in one element and with | as @kidnapkin did, worked.

Please check this with NativeBase 2.3.3

It is not solved . Tried 2.3.3 and transformIgnorePatterns as well.

"native-base": "2.3.3",
"react": "16.0.0-beta.5",
"react-native": "0.49.3",

"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element|react-native-localization|native-base-shoutem-theme|@shoutem/theme|@shoutem/animation|@shoutem/ui|tcomb-form-native)"
],
"setupFiles": [
"./jest-setup.js"
]
},

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

Works for me! 2.3.2

Updating the dependencies is the fix for this
There is a PR open for this #1391

Still have the problem, 2.3.2 with:

"jest": {
  "preset": "react-native",
  "setupFiles": [
    "<rootDir>/__tests__/jest/setup.js"
  ],
  "testPathIgnorePatterns": [
    "<rootDir>/__tests__/jest/",
    "<rootDir>/node_modules/"
  ],
  "transformIgnorePatterns": [
    "node_modules/(?!react-native|native-base-shoutem-theme|react-navigation)"
  ]
}

EDIT:
Updated my transformIgnorePatterns to:

  "transformIgnorePatterns": [
    "node_modules/(?!react-native|native-base|react-navigation)"
  ]

Works fine now.

Check out fixes for jest with 2.5.0
This issue will be closed next week in case of no response

All options for transformIgnorePatterns are not working for me on react-native 0.56

My config for jest and it resolve my problem for suthem lib .

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Landerson352 picture Landerson352  路  3Comments

natashache picture natashache  路  3Comments

Bundas picture Bundas  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments

Cotel picture Cotel  路  3Comments