如何解决排毒:请将两个参数添加到环境构造函数中的 super() 调用
我按照自述文件指南在 React Native 项目中设置了 detox。
detox build
工作正常。但是当我运行 detox test
我收到此错误
FAIL e2e/firstTest.e2e.jsrun...
● Test suite failed to run
Please add both arguments to super() call in your environment constructor,e.g.:
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
- constructor(config) {
- super(config);
+ constructor(config,context) {
+ super(config,context);
Cannot proceed further. Please fix your custom Detox environment class.
at new CustomDetoxEnvironment (environment.js:9:5)
at Generator.next (<anonymous>)
detox[227765] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e
解决方法
Jest
和 jest-circus
的版本必须相同。
您似乎安装了 Detox v18。
您需要执行一些额外的步骤才能使其工作,这些步骤尚未包含在文档中,但可以在此处找到它们: Detox guide for migration to v18
快速解决方案:
-
如果用新语法替换构造函数和超级
class CustomDetoxEnvironment 扩展了 DetoxCircusEnvironment {
- 构造函数(配置){
- super(config);
- 构造函数(配置,上下文){
- super(config,context);
-
您无法再打开应用程序以使用
detox.init()
运行测试。 您需要为此运行device.launchApp()
(强制)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。