Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过docker命令运行cypress时,cypress type()未定义_Docker_Cypress - Fatal编程技术网

通过docker命令运行cypress时,cypress type()未定义

通过docker命令运行cypress时,cypress type()未定义,docker,cypress,Docker,Cypress,在windows 10命令提示符下使用docker命令运行cypress测试时,出现以下错误 docker run-it-v%cd%:/e2e-w/e2e-cypress/包括:3.4.0 但是,当通过npm运行cypress测试时,从windows命令提示符运行cy:test-uattest脚本,所有测试都成功运行。知道为什么在运行docker命令时,cy.type()命令变为“未定义”吗 cy.get('input[name=“firstInput”]')。type(Cypress.env(

在windows 10命令提示符下使用docker命令运行cypress测试时,出现以下错误

docker run-it-v%cd%:/e2e-w/e2e-cypress/包括:3.4.0

但是,当通过
npm运行cypress测试时,从windows命令提示符运行cy:test-uattest
脚本,所有测试都成功运行。知道为什么在运行docker命令时,
cy.type()
命令变为“未定义”吗

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>
CypressError:cy.type()只能接受字符串或数字。你通过了“未定义”
在Object.Cypressur(https://someurl.net/__cypress/runner/cypress_runner.js:84963:11)
投掷者(https://someurl.net/__cypress/runner/cypress_runner.js:84916:18)
在Object.throwerbypath(https://someurl.net/__cypress/runner/cypress_runner.js:84947:17)
在Context.type(https://someurl.net/__cypress/runner/cypress_runner.js:71800:16)
在上下文中。(https://someurl.net/__cypress/runner/cypress_runner.js:80518:21)
在https://someurl.net/__cypress/runner/cypress_runner.js:80223:33
在tryCatcher(https://someurl.net/__cypress/runner/cypress_runner.js:134216:23)
承诺。\你从Handler处获得了和解(https://someurl.net/__cypress/runner/cypress_runner.js:132234:31)
在允诺中(https://someurl.net/__cypress/runner/cypress_runner.js:132291:18)
在允诺中(https://someurl.net/__cypress/runner/cypress_runner.js:132328:10)
异步时。\u drainQueue(https://someurl.net/__cypress/runner/cypress_runner.js:129145:12)
异步时。\u drainQueues(https://someurl.net/__cypress/runner/cypress_runner.js:129150:10)
在

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

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

创建一个包含以下内容的文件
.env
(名称不重要,只要在下一步中使用相同的名称):

CYPRESS_numTestsKeptInMemory=3
CYPRESS_firstNumber=1000
使用以下工具在docker中运行测试:

docker run -it -v %cd%:/e2e -w /e2e --env-file .env cypress/included:3.4.0

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

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

创建一个包含以下内容的文件
.env
(名称不重要,只要在下一步中使用相同的名称):

CYPRESS_numTestsKeptInMemory=3
CYPRESS_firstNumber=1000
使用以下工具在docker中运行测试:

docker run -it -v %cd%:/e2e -w /e2e --env-file .env cypress/included:3.4.0


看起来它找不到您的Cypress.env.json。你把它放在cypress.json旁边了吗?是的,在使用
npm run-cy:test-uattest运行时,所有UI测试都成功运行,没有任何问题。你能运行下面的内容并发布你得到的吗
docker run-it-v%cd%:/e2e-w/e2e-entrypoint ls-cypress/include:3.4.0-lart
-rwxr-xr-x 1 root root 87 Feb 27 11:26 cypress.json-rwxr-xr-x 1 root 125 Feb 27 15:33 cypress.env.json-rwxr-xr-x 1 root 64736 Feb 27 15:43 package-lock.json-rwxr-x 1 root 558 Feb 28 02:14 package.json-xr-xr-x 1 root root2706 Feb 28 02:38 README.md drwxrwxrwx 1 root root 65536 Feb 29 07:12 node_模块drwxrwxrwx 1 root 4096 Feb 29 07:12。drwxrwxrwx 1根根根4096 Feb 29 07:13 cypress drwxr-xr-x 1根根4096 Feb 29 11:06..
。再尝试两件事:1。输出文件并确保其外观良好:
docker run-it-v%cd%:/e2e-w/e2e-entrypoint cat-cypress/include:3.4.0 Config.env.json
。2.在cypress.json中移动变量,看看它是否从那里获取了变量。看起来它找不到您的cypress.env.json。你把它放在cypress.json旁边了吗?是的,在使用
npm run-cy:test-uattest运行时,所有UI测试都成功运行,没有任何问题。你能运行下面的内容并发布你得到的吗
docker run-it-v%cd%:/e2e-w/e2e-entrypoint ls-cypress/include:3.4.0-lart
-rwxr-xr-x 1 root root 87 Feb 27 11:26 cypress.json-rwxr-xr-x 1 root 125 Feb 27 15:33 cypress.env.json-rwxr-xr-x 1 root 64736 Feb 27 15:43 package-lock.json-rwxr-x 1 root 558 Feb 28 02:14 package.json-xr-xr-x 1 root root2706 Feb 28 02:38 README.md drwxrwxrwx 1 root root 65536 Feb 29 07:12 node_模块drwxrwxrwx 1 root 4096 Feb 29 07:12。drwxrwxrwx 1根根根4096 Feb 29 07:13 cypress drwxr-xr-x 1根根4096 Feb 29 11:06..
。再尝试两件事:1。输出文件并确保其外观良好:
docker run-it-v%cd%:/e2e-w/e2e-entrypoint cat-cypress/include:3.4.0 Config.env.json
。2.在cypress.json中移动你的变量,看看它是否从那里获取它们。这是正确的吗?我的环境文件名为
cypress.env.json
,命令如下`docker run-it-v%cd%:/e2e-w/e2e--env file-cypress.env-cypress/include:3.4.0'环境文件不是json。只要在docket run命令中使用相同的名称,并且文件的内容如上所述(根据官方文档),您就可以按照您想要的方式命名它。我已经按照建议尝试了,创建了一个新文件,但仍然不起作用。我需要能够重现该文件以修复它。如果你能找到一种方法让我访问这些信息源,那么我希望我能找出它的错误。这是正确的吗?我的环境文件名为
cypress.env.json
,命令如下`docker run-it-v%cd%:/e2e-w/e2e--env file-cypress.env-cypress/include:3.4.0'环境文件不是json。只要在docket run命令中使用相同的名称,并且文件的内容如上所述(根据官方文档),您就可以按照您想要的方式命名它。我已经按照建议尝试了,创建了一个新文件,但仍然不起作用。我需要能够重现该文件以修复它。如果你能找到一个方法,让我访问的来源,然后希望我能找到什么是错误的。