soccerway
soccerway

Reputation: 11931

While running cypress via docker command, cypress type() getting undefined

While running the cypress test using below docker command from windows 10 command prompt, the below error occurs.

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

But while running the cypress test by npm run cy:test-uattest script from windows command prompt all the test run successfully. Any idea why the cy.type() command becomes 'undefined' while running the docker command.

cy.get('input[name="firstInput"]').type(Cypress.env('firstNumber'));

Below is my Cypress.env.json file

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

Error while running the docker command:

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>

Upvotes: 1

Views: 647

Answers (1)

Mihai
Mihai

Reputation: 10717

Based on the comments, this needs more investigation.

In the meantime, you can use environment variables:

Create a file .env (name is not important, as long as you use the same in the next step) with the following contents:

CYPRESS_numTestsKeptInMemory=3
CYPRESS_firstNumber=1000

Run your tests in docker with:

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

Upvotes: 2

Related Questions