排毒测试:SyntaxError:const 声明中缺少初始化程序
Posted
技术标签:
【中文标题】排毒测试:SyntaxError:const 声明中缺少初始化程序【英文标题】:Detox tests: SyntaxError: Missing initializer in const declaration 【发布时间】:2020-08-22 12:40:17 【问题描述】:我对 React Native 和 Detox 还很陌生,并且在调试此问题的根本原因时遇到了一些问题。
对于我们的测试环境,我们首先使用
npm run e2e -- --docker start
e2e 脚本在 package.json 中定义为
"e2e": "ts-node e2e/runner.ts",
我得到的错误是:
@cb/mobile@0.0.1 e2e /Users/rishabhharit/Documents/GitHub/clearbook/packages/cb-mobile ts-node e2e/runner.ts "--docker" "start" /Users/rishabhharit/Documents/GitHub/clearbook/packages/cb-mobile/node_modules/react-native/Libraries/Utilities/warnOnce.js:15 const warnedKeys: [string]: boolean = ; ^^^^^^^^^^ SyntaxError: Missing initializer in const declaration at wrapSafe (internal/modules/cjs/loader.js:891:16) at Module._compile (internal/modules/cjs/loader.js:941:27) at Module._extensions..js (internal/modules/cjs/loader.js:1011:10) at Object.require.extensions.<computed> [as .js] (/Users/rishabhharit/Documents/GitHub/clearbook/packages/cb-mobile/node_modules/ts-node/src/index.ts:807:44) at Module.load (internal/modules/cjs/loader.js:822:32) at Function.Module._load (internal/modules/cjs/loader.js:730:14) at Module.require (internal/modules/cjs/loader.js:864:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/Users/rishabhharit/Documents/GitHub/clearbook/packages/cb-mobile/node_modules/react-native/Libraries/react-native/react-native-implementation.js:14:18) at Module._compile (internal/modules/cjs/loader.js:971:30) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @cb/mobile@0.0.1 e2e: `ts-node e2e/runner.ts "--docker" "start"` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @cb/mobile@0.0.1 e2e script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/rishabhharit/.npm/_logs/2020-05-07T08_58_41_483Z-debug.log [2020-05-07T08_58_41_483Z-debug.log](https://github.com/wix/Detox/files/4591898/2020-05-07T08_58_41_483Z-debug.log)
runner.ts.zip
现在我不确定在哪里看。将根据要求提供更多信息。
【问题讨论】:
【参考方案1】:这个答案帮助了我https://***.com/a/57254546。
只需将此行添加到e2e/config.json
:
"preset": "react-native"
【讨论】:
以上是关于排毒测试:SyntaxError:const 声明中缺少初始化程序的主要内容,如果未能解决你的问题,请参考以下文章