Cypress UI 自动化(8)- 使用docker命令运行cypress项目,碰到的问题

1、Docker重复运行cypress项目,提示“ The container name "/cypress-docker" is already in use by container”

解决方案1:使用‘docker rm’删除掉该容器后,再重新运行cypress项目

解决方案2:修改容器名称(--name),再重新运行cypress项目 

docker run -it -v /usr/zhoulm/cypress/:/e2e -w /e2e --name=cypress-docker-1 suyunrong/cypress:3.2.0

解决方案3:运行cypress项目的命令添加“--rm”选项,每次运行后,自动删除刚刚运行的容器实例

docker run --rm -it -v /usr/zhoulm/cypress/:/e2e -w /e2e --name=cypress-docker suyunrong/cypress:3.2.0
#--rm: 运行完后删除该容器

2、使用docker镜像(cypress/included:4.10.0)运行,提示“We detected that the Chromium Renderer process just crashed” 

说明:对应项目在UI界面模式下,或者非docker环境下的命令行运行,都是ok的。

1、查看终端的提示,建议我们查看:https://on.cypress.io/renderer-process-crashed
2、进入https://github.com/cypress-io/cypress/issues/350,官方解释:并不一定时内存溢出的问题,而是与浏览器的后台运行方式有关

3、解决方案,在命令行中加个flag: --ipc=host

docker run --rm --ipc=host -it -v /usr/zhoulm/cypress/:/e2e -w /e2e --name=cypress-docker suyunrong/cypress:4.10.0
4、IPC设置解释(其实并没有理解,但问题是解决了,cypress官网说后面将会提供更好的解决方案)
--ipc=""  : Set the IPC mode for the container,             
            'container:<name|id>': reuses another container's IPC namespace             
            'host': use the host's IPC namespace inside the container

默认情况下,所有容器都启用了 IPC 命名空间。

IPC(POSIX / SysV IPC)命名空间提供命名共享内存段,信号量和消息队列的分离。

共享内存段用于以内存速度加速进程间通信,而不是通过管道或通过网络堆栈。共享内存通常由数据库和定制(通常为C / OpenMPI,C ++ /使用boost库)用于科学计算和金融服务行业的高性能应用程序使用。如果这些类型的应用程序分成多个容器,则可能需要共享容器的IPC机制。

3、cypress运行时报异常错误:“The following error originated from your application code, not from Cypress.    > ResizeObserver loop limit exceeded ”

CypressError: The following error originated from your application code, not from Cypress.

  > ResizeObserver loop limit exceeded

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

https://on.cypress.io/uncaught-exception-from-application
    at cypressErr (http://10.10.13.26:8081/__cypress/runner/cypress_runner.js:170112:16)
    at Object.errByPath (http://10.10.13.26:8081/__cypress/runner/cypress_runner.js:170167:10)
    at Object.createUncaughtException (http://10.10.13.26:8081/__cypress/runner/cypress_runner.js:159999:45)
    at $Cy.onUncaughtException (http://10.10.13.26:8081/__cypress/runner/cypress_runner.js:167810:24)
    at onError (http://10.10.13.26:8081/__cypress/runner/cypress_runner.js:166872:39)
From Your Spec Code:
    at Context.eval (http://10.10.13.26:8081/__cypress/tests?p=cypress/support/index.js:171:124)

不一定是docker模式运行才会出现。

cypress给出的错误解释:应用程序代码超出ResizeObserver循环限制,当cypress检测到源自您应用程序的未捕获错误时,它将自动使当前测试失败。

解决方案:这种行为是可配置的,在cypress/support/index.js中可以选择通过监听`uncaught:exception`事件来关闭此行为。

Cypress.on('uncaught:exception', (err, runnable) => {
        // returning false here prevents Cypress from
        // failing the test
        return false
})

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值