gpt4 book ai didi

docker - 通过docker命令运行cypress时,cypress type()变得不确定

转载 作者:行者123 更新时间:2023-12-02 21:00:41 32 4
gpt4 key购买 nike

在Windows 10命令提示符下使用以下docker命令运行cypress测试时,发生以下错误。
docker run -it -v %cd%:/e2e -w /e2e cypress/included:3.4.0
但是,在从Windows命令通过npm run cy:test-uattest脚本运行cypress测试时,所有测试均成功运行。知道为什么在运行docker命令时cy.type()命令变为“undefined”。
cy.get('input[name="firstInput"]').type(Cypress.env('firstNumber'));
以下是我的Cypress.env.json文件

{
"numTestsKeptInMemory": 3,
"firstNumber":"1000"
}

运行docker命令时出错:
CypressError: cy.type() can only accept a String or Number. You passed in: 'undefined'
at Object.cypressErr (https://someurl.net/__cypress/runner/cypress_runner.js:84963:11)
at Object.throwErr (https://someurl.net/__cypress/runner/cypress_runner.js:84916:18)
at Object.throwErrByPath (https://someurl.net/__cypress/runner/cypress_runner.js:84947:17)
at Context.type (https://someurl.net/__cypress/runner/cypress_runner.js:71800:16)
at Context.<anonymous> (https://someurl.net/__cypress/runner/cypress_runner.js:80518:21)
at https://someurl.net/__cypress/runner/cypress_runner.js:80223:33
at tryCatcher (https://someurl.net/__cypress/runner/cypress_runner.js:134216:23)
at Promise._settlePromiseFromHandler (https://someurl.net/__cypress/runner/cypress_runner.js:132234:31)
at Promise._settlePromise (https://someurl.net/__cypress/runner/cypress_runner.js:132291:18)
at Promise._settlePromiseCtx (https://someurl.net/__cypress/runner/cypress_runner.js:132328:10)
at Async._drainQueue (https://someurl.net/__cypress/runner/cypress_runner.js:129145:12)
at Async._drainQueues (https://someurl.net/__cypress/runner/cypress_runner.js:129150:10)
at <anonymous>

最佳答案

根据评论,这需要更多调查。

同时,您可以使用环境变量:

创建具有以下内容的文件.env(名称不重要,只要您在下一步中使用该文件即可):

CYPRESS_numTestsKeptInMemory=3
CYPRESS_firstNumber=1000

使用以下命令在docker中运行测试:
docker run -it -v %cd%:/e2e -w /e2e --env-file .env cypress/included:3.4.0

关于docker - 通过docker命令运行cypress时,cypress type()变得不确定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60463893/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com