ui
ui copied to clipboard
Jest gets confused by Shoutem
The Jest test runner seems to get confused by Shoutem.
Steps to reproduce:
react-native init jestShoutemyarn add @shoutem/ui- (in
index.android.js) addimport { Text } from '@shoutem/ui'; jest
Jest gives the output
FAIL __tests__\index.android.js
● Test suite failed to run
D:\Code\shoutemJest\node_modules\@shoutem\ui\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { setDefaultThemeStyle } from './init';
^^^^^^
SyntaxError: Unexpected token import
at transformAndBuildScript (node_modules\jest-runtime\build\transform.js:320:12)
at Object.<anonymous> (index.android.js:13:9)
at Object.<anonymous> (__tests__\index.android.js:3:19)
Using Jest version 18.1.0, React Native version 0.41.0, node version 7.5.0, yarn version 0.19.1, @shoutem/ui version 0.10.8
@markspolakovs in package.json
{
// ...
"jest": {
// ...
"transformIgnorePatterns": [
"node_modules/(?!react-native|@shoutem/theme|@shoutem/animation|@shoutem/ui)"
]
}
// ...
}
This is due to a problem with the jest configuration. It looks like the official recommendation is to use the transformIgnorePatters described above (https://github.com/facebook/jest/issues/2081), so I am closing this for now. Please let us know if anyone finds a better solution for this.