You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
问题描述
用Jest测试一个自定义组件,该组件中使用了taro-ui组件。运行测试后报错:
Test suite failed to run
\node_modules\_taro-ui@2.2.1@taro-ui\dist\weapp\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Taro from '@tarojs/taro'
^^^^
SyntaxError: Unexpected identifier
at ScriptTransformer._transformAndBuildScript (node_modules/_jest-runtime@23.6.0@jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/_taro-ui@2.2.1@taro-ui/dist/index.js:5:22)
\node_modules\_taro-ui@2.2.1@taro-ui\dist\weapp\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Taro from '@tarojs/taro'
^^^^
SyntaxError: Unexpected identifier
at ScriptTransformer._transformAndBuildScript (node_modules/_jest-runtime@23.6.0@jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/_taro-ui@2.2.1@taro-ui/dist/index.js:5:22)
系统信息
Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。
问题描述
用Jest测试一个自定义组件,该组件中使用了taro-ui组件。运行测试后报错:
Test suite failed to run
可以发现,这里应用了微信版本的taro-ui文件: \node_modules_taro-ui@2.2.1@taro-ui\dist\weapp\index.js:1
在taro-ui\dist\index.js中,有如下代码:
Jest测试时,TARO_ENV未定义,所以使用了微信版本的taro-ui文件。但我找不到地方去设置TARO_ENV。
请帮忙解决这个问题,谢谢
复现步骤
[复现问题的步骤]
期望行为
测试用例能运行
报错信息
系统信息
👽 Taro v1.3.10
Taro CLI 1.3.10 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]
Jest测试时,TARO_ENV未定义,所以使用了微信版本的taro-ui文件。但我找不到地方去设置TARO_ENV。
The text was updated successfully, but these errors were encountered: