Skip to content

Commit

Permalink
add skipped tests showing problem (#530)
Browse files Browse the repository at this point in the history
* add skipped tests showing problem

* skip failing test
  • Loading branch information
bahmutov authored Jul 16, 2020
1 parent 8b5cb04 commit d9d13be
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/server-communication__env-variables/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Server communication: passing environment variables

This recipe shows how to pass environment variables to your tests
This recipe shows how to pass [environment variables to your tests](https://on.cypress.io/environment-variables)

- See [package.json](package.json) file which runs Cypress with environment variables set. The variables that start with `CYPRESS_` are extracted automatically. Other variables are copied from `process.env` in the script [cypress/plugins/index.js](cypress/plugins/index.js)
- Additional variables can be passed via `env` object in [cypress.json](cypress.json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,57 @@ describe('process environment variables', () => {
api_server: 'http://localhost:8888/api/v1/',
})
})

context('Suite env variables', {
env: {
suiteApi: 'https://staging.dev',
commonFlag: 'suite',
},
}, () => {
it('has all environment variables', () => {
expect(Cypress.env('suiteApi')).to.equal('https://staging.dev')
})

// NOTE: does not work, seems test variables override
// the suite variables but in a weird way (even after commenting out and
// reloading the old variable is still there!)
// https://github.com/cypress-io/cypress/issues/8005
it.skip('has test-specific env variables', {
env: {
testFlag: 42,
commonFlag: 'test',
},
}, () => {
expect(Cypress.env('testFlag'), 'test level variable').to.equal(42)
expect(Cypress.env('commonFlag'), 'test overrides suite').to.equal('test')
expect(Cypress.env('suiteApi'), 'suite level variable').to.equal('https://staging.dev')
})

it('has its own variable 1', {
env: {
testOne: true,
},
}, () => {
expect(Cypress.env()).to.include({
testOne: true,
})
})

// NOTE: leaking variable from previous test
// https://github.com/cypress-io/cypress/issues/8005
it.skip('has its own variable 2', {
env: {
testTwo: true,
},
}, () => {
expect(Cypress.env(), 'has variable from this test').to.include({
testTwo: true,
})

cy.log(Object.keys(Cypress.env()).join(', '))
.then(() => {
expect(Cypress.env(), 'does not have variable from first test').to.not.have.property('testOne')
})
})
})
})

0 comments on commit d9d13be

Please sign in to comment.