Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/driver/cypress/integration/commands/task_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('src/cy/commands/task', () => {
expect(lastLog.get('error')).to.eq(err)
expect(lastLog.get('state')).to.eq('failed')

expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the plugins file. The following tasks are registered: return:arg, arg:is:undefined, wait, create:long:file\n\nFix this in your plugins file here:\n${Cypress.config('pluginsFile')}`)
expect(err.message).to.eq(`\`cy.task('bar')\` failed with the following error:\n\nThe task 'bar' was not handled in the plugins file. The following tasks are registered: return:arg, cypress:env, arg:is:undefined, wait, create:long:file\n\nFix this in your plugins file here:\n${Cypress.config('pluginsFile')}`)

done()
})
Expand Down
5 changes: 5 additions & 0 deletions packages/driver/cypress/integration/issues/18805_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('CYPRESS env var', () => {
it('checks that the CYPRESS env var exists in the plugin file', () => {
cy.task('cypress:env').should('eq', 'true')
})
})
3 changes: 3 additions & 0 deletions packages/driver/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ module.exports = (on) => {
'return:arg' (arg) {
return arg
},
'cypress:env' () {
return process.env['CYPRESS']
},
'arg:is:undefined' (arg) {
if (arg === undefined) {
return 'arg was undefined'
Expand Down
2 changes: 2 additions & 0 deletions packages/server/lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const pkg = require('@packages/root')
// or development as default
const env = process.env['CYPRESS_INTERNAL_ENV'] || (process.env['CYPRESS_INTERNAL_ENV'] = pkg.env != null ? pkg.env : 'development')

process.env['CYPRESS'] = 'true'

const config = {
// uses cancellation for automation timeouts
cancellation: true,
Expand Down
6 changes: 6 additions & 0 deletions packages/server/test/unit/environment_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ describe('lib/environment', () => {
return expectedEnv('development')
})
})

context('it sets process.env.CYPRESS', () => {
it('sets CYPRESS=true when Cypress runs', () => {
expect(process.env['CYPRESS']).to.eq('true')
})
})
})