fix: use util.getEnv to handle environment variables set with npm (#19560)

Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
This commit is contained in:
Pascal Gafner
2022-01-12 15:52:26 +01:00
committed by GitHub
parent 0382768981
commit 576519e465
2 changed files with 9 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ const logger = require('../logger')
const xvfb = require('../exec/xvfb')
const state = require('./state')
const VERIFY_TEST_RUNNER_TIMEOUT_MS = +process.env.CYPRESS_VERIFY_TIMEOUT || 30000
const VERIFY_TEST_RUNNER_TIMEOUT_MS = +util.getEnv('CYPRESS_VERIFY_TIMEOUT') || 30000
const checkExecutable = (binaryDir) => {
const executable = state.getPathToExecutable(binaryDir)

View File

@@ -81,6 +81,14 @@ context('lib/tasks/verify', () => {
expect(newVerifyInstance.VERIFY_TEST_RUNNER_TIMEOUT_MS).to.eql(500000)
})
it('accepts custom verify task timeout from npm', () => {
process.env.npm_config_CYPRESS_VERIFY_TIMEOUT = '500000'
delete require.cache[require.resolve(`${lib}/tasks/verify`)]
const newVerifyInstance = require(`${lib}/tasks/verify`)
expect(newVerifyInstance.VERIFY_TEST_RUNNER_TIMEOUT_MS).to.eql(500000)
})
it('falls back to default verify task timeout if custom value is invalid', () => {
process.env.CYPRESS_VERIFY_TIMEOUT = 'foobar'
delete require.cache[require.resolve(`${lib}/tasks/verify`)]