ui icon indicating copy to clipboard operation
ui copied to clipboard

Jest gets confused by Shoutem

Open markspolakovs opened this issue 9 years ago • 2 comments

The Jest test runner seems to get confused by Shoutem.

Steps to reproduce:

  1. react-native init jestShoutem
  2. yarn add @shoutem/ui
  3. (in index.android.js) add import { Text } from '@shoutem/ui';
  4. 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 avatar Feb 05 '17 17:02 markspolakovs

@markspolakovs in package.json

{
  // ...
  "jest": {
    // ...
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|@shoutem/theme|@shoutem/animation|@shoutem/ui)"
    ]
  }
  // ...
}

vitalyrotari avatar Feb 06 '17 16:02 vitalyrotari

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.

zrumenjak avatar Apr 06 '17 12:04 zrumenjak