Skip to content

Commit c87568a

Browse files
Merge branch 'develop' into fix-test-config-only
2 parents 0180e12 + de4fca3 commit c87568a

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

packages/driver/cypress/integration/commands/task_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ describe('src/cy/commands/task', () => {
210210
expect(lastLog.get('error')).to.eq(err)
211211
expect(lastLog.get('state')).to.eq('failed')
212212

213-
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')}`)
213+
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')}`)
214214

215215
done()
216216
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('CYPRESS env var', () => {
2+
it('checks that the CYPRESS env var exists in the plugin file', () => {
3+
cy.task('cypress:env').should('eq', 'true')
4+
})
5+
})

packages/driver/cypress/plugins/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ module.exports = (on) => {
3838
'return:arg' (arg) {
3939
return arg
4040
},
41+
'cypress:env' () {
42+
return process.env['CYPRESS']
43+
},
4144
'arg:is:undefined' (arg) {
4245
if (arg === undefined) {
4346
return 'arg was undefined'

packages/server/lib/environment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const pkg = require('@packages/root')
2525
// or development as default
2626
const env = process.env['CYPRESS_INTERNAL_ENV'] || (process.env['CYPRESS_INTERNAL_ENV'] = pkg.env != null ? pkg.env : 'development')
2727

28+
process.env['CYPRESS'] = 'true'
29+
2830
const config = {
2931
// uses cancellation for automation timeouts
3032
cancellation: true,

packages/server/test/unit/environment_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,10 @@ describe('lib/environment', () => {
134134
return expectedEnv('development')
135135
})
136136
})
137+
138+
context('it sets process.env.CYPRESS', () => {
139+
it('sets CYPRESS=true when Cypress runs', () => {
140+
expect(process.env['CYPRESS']).to.eq('true')
141+
})
142+
})
137143
})

0 commit comments

Comments
 (0)