mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-15 11:40:07 -06:00
* WIP: add cli info command to list detected browsers * print found browsers * change to list * start work on info command calling into binary * move info command into binary * print OS info during cypress info command * add binary cache path to info command * add browser profile path * add memory * get browser profile path without partition * pick real browsers as examples * output same info as desired * better names * changed colors * add list of cached binary versions * do not put stable into name * add underlined link * conditionally show profile path, only if the folder exists * do not list cached binaries * human-friendly memory print * print env proxy vars * print CYPRESS_ env variables * use _.sample * update order * store cypress info output on CI as HTML page artifact * add percy CLI screenshots * sanitize cypress info command * store CLI snapshots in cli/visual-snapshots folder * update cli unit snapshot * add cli unit test * start e2e testing for cypress info * add test with proxy and cypress vars * make sure we call the binary * stricter start check * start unit testing modes info * test info mode browser print * add test for profile path * add cypress info command to test binary Circle job * add cypress info to test-binary-as-specific-user circle * print cypress info --dev on circle and on appveyor * update .gitignore * move error in environment load to debug
72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
require('../../spec_helper')
|
|
|
|
const os = require('os')
|
|
const util = require(`${lib}/util`)
|
|
const state = require(`${lib}/tasks/state`)
|
|
const info = require(`${lib}/exec/info`)
|
|
const spawn = require(`${lib}/exec/spawn`)
|
|
|
|
const snapshot = require('../../support/snapshot')
|
|
const stdout = require('../../support/stdout')
|
|
const normalize = require('../../support/normalize')
|
|
|
|
describe('exec info', function () {
|
|
beforeEach(function () {
|
|
sinon.stub(process, 'exit')
|
|
|
|
// common stubs
|
|
sinon.stub(spawn, 'start').resolves()
|
|
os.platform.returns('linux')
|
|
sinon.stub(os, 'totalmem').returns(1.2e+9)
|
|
sinon.stub(os, 'freemem').returns(4e+8)
|
|
sinon.stub(info, 'findProxyEnvironmentVariables').returns({})
|
|
sinon.stub(info, 'findCypressEnvironmentVariables').returns({})
|
|
sinon.stub(util, 'getApplicationDataFolder')
|
|
.withArgs('browsers').returns('/user/app/data/path/to/browsers')
|
|
.withArgs().returns('/user/app/data/path')
|
|
|
|
sinon.stub(state, 'getCacheDir').returns('/user/path/to/binary/cache')
|
|
})
|
|
|
|
const startInfoAndSnapshot = async (snapshotName) => {
|
|
expect(snapshotName, 'missing snapshot name').to.be.a('string')
|
|
|
|
const output = stdout.capture()
|
|
|
|
await info.start()
|
|
stdout.restore()
|
|
|
|
snapshot(snapshotName, normalize(output.toString()))
|
|
}
|
|
|
|
it('prints collected info without env vars', async () => {
|
|
await startInfoAndSnapshot('cypress info without browsers or vars')
|
|
expect(spawn.start).to.be.calledWith(['--mode=info'], { dev: undefined })
|
|
})
|
|
|
|
it('prints proxy and cypress env vars', async () => {
|
|
info.findProxyEnvironmentVariables.returns({
|
|
PROXY_ENV_VAR1: 'some proxy variable',
|
|
PROXY_ENV_VAR2: 'another proxy variable',
|
|
})
|
|
|
|
info.findCypressEnvironmentVariables.returns({
|
|
CYPRESS_ENV_VAR1: 'my Cypress variable',
|
|
CYPRESS_ENV_VAR2: 'my other Cypress variable',
|
|
})
|
|
|
|
await startInfoAndSnapshot('cypress info with proxy and vars')
|
|
})
|
|
|
|
it('redacts sensitive cypress variables', async () => {
|
|
info.findCypressEnvironmentVariables.returns({
|
|
CYPRESS_ENV_VAR1: 'my Cypress variable',
|
|
CYPRESS_ENV_VAR2: 'my other Cypress variable',
|
|
CYPRESS_PROJECT_ID: 'abc123', // not sensitive
|
|
CYPRESS_RECORD_KEY: 'really really secret stuff', // should not be printed
|
|
})
|
|
|
|
await startInfoAndSnapshot('cypress redacts sensitive vars')
|
|
})
|
|
})
|