Jest测试失败的意外导出反应原生

时间:2017-11-21 13:04:41

标签: react-native jestjs expo

我刚刚生成了React-Native项目,yarn test失败了。

package.json文件中存在

jest-expo预设。

FAIL  ./App.test.js
 ● Test suite failed to run

   /Users/haito/Projects/react-native/TalkToMe/node_modules/react-router-native/main.js:1
   ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from 'react-router'
                                                                                            ^^^^^^

   SyntaxError: Unexpected token export

     at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:305:17)
     at Object.<anonymous> (App.js:2:24)
     at Object.<anonymous> (App.test.js:2:10)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.071s
Ran all test suites.

编辑添加的babel预设:

 FAIL  ./App.test.js
  ● Test suite failed to run

    [BABEL] /Users/haito/Projects/react-native/TalkToMe/node_modules/react-native/jest/setup.js: Plugin/Preset files are not allowed to export objects, only functions.

      at createDescriptor (node_modules/@babel/core/lib/config/option-manager.js:303:11)
      at node_modules/@babel/core/lib/config/option-manager.js:154:12
          at Array.map (<anonymous>)
      at node_modules/@babel/core/lib/config/option-manager.js:153:48
      at cachedFunction (node_modules/@babel/core/lib/config/caching.js:48:17)
      at OptionManager.mergeOptions (node_modules/@babel/core/lib/config/option-manager.js:47:18)
      at OptionManager.init (node_modules/@babel/core/lib/config/option-manager.js:115:14)
      at manageOptions (node_modules/@babel/core/lib/config/option-manager.js:31:30)
      at loadConfig (node_modules/@babel/core/lib/config/index.js:15:37)
      at transformSync (node_modules/@babel/core/lib/transform-sync.js:13:36)

0 个答案:

没有答案