mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-29 19:41:16 -05:00
cli: expose method that parses cypress run CLI logic (#7798)
Co-authored-by: Zach Bloomquist <github@chary.us>
This commit is contained in:
@@ -172,4 +172,71 @@ describe('cypress', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
context('cli', function () {
|
||||
describe('.parseRunArguments', function () {
|
||||
it('parses CLI cypress run arguments', async () => {
|
||||
const args = 'cypress run --browser chrome --spec my/test/spec.js'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
expect(options).to.deep.equal({
|
||||
browser: 'chrome',
|
||||
spec: 'my/test/spec.js',
|
||||
})
|
||||
})
|
||||
|
||||
it('parses CLI cypress run shorthand arguments', async () => {
|
||||
const args = 'cypress run -b firefox -p 5005 --headed --quiet'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
expect(options).to.deep.equal({
|
||||
browser: 'firefox',
|
||||
port: 5005,
|
||||
headed: true,
|
||||
quiet: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('coerces --record and --dev', async () => {
|
||||
const args = 'cypress run --record false --dev true'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
expect(options).to.deep.equal({
|
||||
record: false,
|
||||
dev: true,
|
||||
})
|
||||
})
|
||||
|
||||
it('parses config file false', async () => {
|
||||
const args = 'cypress run --config-file false'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
expect(options).to.deep.equal({
|
||||
configFile: false,
|
||||
})
|
||||
})
|
||||
|
||||
it('parses config', async () => {
|
||||
const args = 'cypress run --config baseUrl=localhost,video=true'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
// we don't need to convert the config into an object
|
||||
// since the logic inside cypress.run handles that
|
||||
expect(options).to.deep.equal({
|
||||
config: 'baseUrl=localhost,video=true',
|
||||
})
|
||||
})
|
||||
|
||||
it('parses env', async () => {
|
||||
const args = 'cypress run --env MY_NUMBER=42,MY_FLAG=true'.split(' ')
|
||||
const options = await cypress.cli.parseRunArguments(args)
|
||||
|
||||
// we don't need to convert the environment into an object
|
||||
// since the logic inside cypress.run handles that
|
||||
expect(options).to.deep.equal({
|
||||
env: 'MY_NUMBER=42,MY_FLAG=true',
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user