在windows 10命令提示符下使用以下docker命令运行cypress测试时,出现以下错误。
docker run -it -v %cd%:/e2e -w /e2e cypress/included:3.4.0
但是,在windows命令提示符下通过npm run cy:test-uattest脚本运行cypress测试时,所有测试都运行成功。知道为什么cy.type()命令在运行docker命令时变得“未定义”吗?
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>发布于 2020-02-29 23:14:37
根据评论,这需要更多的调查。
同时,您可以使用环境变量:
创建一个包含以下内容的文件.env (名称并不重要,只要您在下一步中使用名称即可):
CYPRESS_numTestsKeptInMemory=3
CYPRESS_firstNumber=1000使用以下命令在docker中运行测试:
docker run -it -v %cd%:/e2e -w /e2e --env-file .env cypress/included:3.4.0https://stackoverflow.com/questions/60463893
复制相似问题