【问题标题】:getting test failed on typing command npm test输入命令 npm test 时测试失败
【发布时间】:2019-08-04 23:47:17
【问题描述】:

我收到一个错误,导致返回测试失败。无法找到解决方案。已检查但没有找到合适的答案

我尝试了以下方法: 1.检查babel版本:使用7.5.5 2.https://github.com/GeekyAnts/NativeBase/issues/977 3.https://gist.github.com/iamvery/4d4b0ef68cd1f2de81b858fe3a2d08c5 4.https://github.com/GeekyAnts/NativeBase/issues/2579

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import connectStyle, { clearThemeCache } from "./src/connectStyle";

SyntaxError: Unexpected identifier

      at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (../../node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at Object.<anonymous> (../../node_modules/native-base/src/index.js:1:1)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       4 passed, 4 total
Snapshots:   1 passed, 1 total
Time:        2.022s
Ran all test suites.
npm ERR! Test failed.  See above for more details.

实际结果如上图所示测试失败

预期结果是测试应该通过

【问题讨论】:

    标签: react-native jestjs


    【解决方案1】:

    你可以把它添加到你的 jest 配置文件中

    "transformIgnorePatterns": [ "node_modules/(?!react-native|@shoutem|react-clone-referenced-element|native-base-shoutem-theme)" ]
    

    【讨论】:

      猜你喜欢
      • 2021-05-28
      • 2016-12-09
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-01
      相关资源
      最近更新 更多