Skip to content

Commit

Permalink
Merge branch '10.0-release' into chore/update-vite-2.9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaSachs committed Mar 21, 2022
2 parents fecccf4 + e5d7fd8 commit 74656d2
Show file tree
Hide file tree
Showing 47 changed files with 217 additions and 308 deletions.
10 changes: 3 additions & 7 deletions circle.yml
Expand Up @@ -29,7 +29,7 @@ mainBuildFilters: &mainBuildFilters
only:
- develop
- 10.0-release
- marktnoonan/backmerge-develop-3-8-22
- UNIFY-1294-specs-list-flake

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -39,7 +39,7 @@ macWorkflowFilters: &mac-workflow-filters
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ '10.0-release', << pipeline.git.branch >> ]
- equal: [ marktnoonan/backmerge-develop-3-8-22, << pipeline.git.branch >> ]
- equal: [ UNIFY-1294-specs-list-flake, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand All @@ -49,7 +49,7 @@ windowsWorkflowFilters: &windows-workflow-filters
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ '10.0-release', << pipeline.git.branch >> ]
- equal: [ marktnoonan/backmerge-develop-3-8-22, << pipeline.git.branch >> ]
- equal: [ UNIFY-1294-specs-list-flake, << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -1689,7 +1689,6 @@ jobs:
steps:
- clone-repo-and-checkout-branch:
repo: cypress-example-kitchensink
pull_request_id: 524
- install-required-node
- run:
name: Remove cypress.json
Expand Down Expand Up @@ -2005,23 +2004,20 @@ jobs:
- test-binary-against-repo:
repo: cypress-example-kitchensink
browser: "electron"
pull_request_id: 524

test-binary-against-kitchensink-firefox:
<<: *defaults
steps:
- test-binary-against-repo:
repo: cypress-example-kitchensink
browser: firefox
pull_request_id: 524

test-binary-against-kitchensink-chrome:
<<: *defaults
steps:
- test-binary-against-repo:
repo: cypress-example-kitchensink
browser: chrome
pull_request_id: 524

test-binary-against-todomvc-firefox:
<<: *defaults
Expand Down
5 changes: 2 additions & 3 deletions cli/__snapshots__/cli_spec.js
Expand Up @@ -26,8 +26,7 @@ exports['shows help for open --foo 1'] = `
cypress.config.{ts|js}.
-C, --config-file <config-file> path to script file where configuration
values are set. defaults to
"cypress.config.{ts|js}". pass "false" to
disable.
"cypress.config.{ts|js}".
-d, --detached [bool] runs Cypress application in detached mode
--e2e runs end to end tests
-e, --env <env> sets environment variables. separate
Expand Down Expand Up @@ -72,7 +71,7 @@ exports['shows help for run --foo 1'] = `
--ci-build-id <id> the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers
--component runs component tests
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.
-C, --config-file <config-file> path to script file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.
-C, --config-file <config-file> path to script file where configuration values are set. defaults to "cypress.config.{ts|js}".
--e2e runs end to end tests
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.config.{ts|js} or cypress.env.json
--group <name> a named group for recorded runs in the Cypress Dashboard
Expand Down
1 change: 1 addition & 0 deletions cli/__snapshots__/errors_spec.js
Expand Up @@ -83,6 +83,7 @@ exports['errors individual has the following errors 1'] = [
"incompatibleTestTypeFlags",
"incompatibleTestingTypeAndFlag",
"invalidCacheDirectory",
"invalidConfigFile",
"invalidCypressEnv",
"invalidOS",
"invalidRunProjectPath",
Expand Down
7 changes: 0 additions & 7 deletions cli/__snapshots__/run_spec.js
Expand Up @@ -21,13 +21,6 @@ exports['exec run .processRunOptions passes --record option 1'] = [
"my record id"
]

exports['exec run .processRunOptions passes --config-file false option 1'] = [
"--run-project",
null,
"--config-file",
false
]

exports['exec run .processRunOptions defaults to e2e testingType 1'] = [
"--run-project",
null
Expand Down
10 changes: 1 addition & 9 deletions cli/lib/cli.js
Expand Up @@ -22,10 +22,6 @@ function unknownOption (flag, type = 'option') {
}
commander.Command.prototype.unknownOption = unknownOption

const coerceFalseOrString = (arg) => {
return arg !== 'false' ? arg : false
}

const coerceFalse = (arg) => {
return arg !== 'false'
}
Expand Down Expand Up @@ -106,7 +102,7 @@ const descriptions = {
ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers',
component: 'runs component tests',
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.config.{ts|js}.',
configFile: 'path to script file where configuration values are set. defaults to "cypress.config.{ts|js}". pass "false" to disable.',
configFile: 'path to script file where configuration values are set. defaults to "cypress.config.{ts|js}".',
detached: 'runs Cypress application in detached mode',
dev: 'runs cypress in development and bypasses binary check',
e2e: 'runs end to end tests',
Expand Down Expand Up @@ -315,10 +311,6 @@ const castCypressOptions = (opts) => {
castOpts.port = coerceAnyStringToInt(opts.port)
}

if (_.has(opts, 'configFile')) {
castOpts.configFile = coerceFalseOrString(opts.configFile)
}

return castOpts
}

Expand Down
6 changes: 6 additions & 0 deletions cli/lib/errors.js
Expand Up @@ -230,6 +230,11 @@ const incompatibleTestingTypeAndFlag = {
solution: 'Either set `testingType` or pass a testing type flag, but not both.',
}

const invalidConfigFile = {
description: '`--config-file` cannot be false.',
solution: 'Either pass a relative path to a valid Cypress config file or remove this option.',
}

/**
* This error happens when CLI detects that the child Test Runner process
* was killed with a signal, like SIGBUS
Expand Down Expand Up @@ -424,5 +429,6 @@ module.exports = {
invalidTestingType,
incompatibleTestTypeFlags,
incompatibleTestingTypeAndFlag,
invalidConfigFile,
},
}
26 changes: 18 additions & 8 deletions cli/lib/exec/open.js
Expand Up @@ -2,7 +2,8 @@ const debug = require('debug')('cypress:cli')
const util = require('../util')
const spawn = require('./spawn')
const verify = require('../tasks/verify')
const { processTestingType } = require('./shared')
const { processTestingType, checkConfigFile } = require('./shared')
const { exitWithError } = require('../errors')

/**
* Maps options collected by the CLI
Expand All @@ -25,6 +26,7 @@ const processOpenOptions = (options = {}) => {
}

if (options.configFile !== undefined) {
checkConfigFile(options)
args.push('--config-file', options.configFile)
}

Expand Down Expand Up @@ -67,14 +69,22 @@ const processOpenOptions = (options = {}) => {
module.exports = {
processOpenOptions,
start (options = {}) {
const args = processOpenOptions(options)

function open () {
return spawn.start(args, {
dev: options.dev,
detached: Boolean(options.detached),
stdio: 'inherit',
})
try {
const args = processOpenOptions(options)

return spawn.start(args, {
dev: options.dev,
detached: Boolean(options.detached),
stdio: 'inherit',
})
} catch (err) {
if (err.details) {
return exitWithError(err.details)()
}

throw err
}
}

if (options.dev) {
Expand Down
19 changes: 9 additions & 10 deletions cli/lib/exec/run.js
Expand Up @@ -5,7 +5,7 @@ const util = require('../util')
const spawn = require('./spawn')
const verify = require('../tasks/verify')
const { exitWithError, errors } = require('../errors')
const { processTestingType, throwInvalidOptionError } = require('./shared')
const { processTestingType, throwInvalidOptionError, checkConfigFile } = require('./shared')

/**
* Typically a user passes a string path to the project.
Expand Down Expand Up @@ -58,6 +58,7 @@ const processRunOptions = (options = {}) => {
}

if (options.configFile !== undefined) {
checkConfigFile(options)
args.push('--config-file', options.configFile)
}

Expand Down Expand Up @@ -164,23 +165,21 @@ module.exports = {
})

function run () {
let args

try {
args = processRunOptions(options)
const args = processRunOptions(options)

debug('run to spawn.start args %j', args)

return spawn.start(args, {
dev: options.dev,
})
} catch (err) {
if (err.details) {
return exitWithError(err.details)()
}

throw err
}

debug('run to spawn.start args %j', args)

return spawn.start(args, {
dev: options.dev,
})
}

if (options.dev) {
Expand Down
12 changes: 12 additions & 0 deletions cli/lib/exec/shared.js
Expand Up @@ -47,7 +47,19 @@ const processTestingType = (options) => {
return []
}

/**
* Throws an error if configFile is string 'false' or boolean false
* @param {*} options
*/
const checkConfigFile = (options) => {
// CLI will parse as string, module API can pass in boolean
if (options.configFile === 'false' || options.configFile === false) {
throwInvalidOptionError(errors.invalidConfigFile)
}
}

module.exports = {
throwInvalidOptionError,
processTestingType,
checkConfigFile,
}
42 changes: 0 additions & 42 deletions cli/test/lib/cypress_spec.js
Expand Up @@ -53,18 +53,6 @@ describe('cypress', function () {
expect(args).to.deep.eq({ config: JSON.stringify(config) })
})
})

it('passes configFile: false', () => {
const opts = {
configFile: false,
}

return cypress.open(opts)
.then(getStartArgs)
.then((args) => {
expect(args).to.deep.eq(opts)
})
})
})

context('.run fails to write results file', function () {
Expand Down Expand Up @@ -152,18 +140,6 @@ describe('cypress', function () {
return cypress.run().then(snapshot)
})

it('passes configFile: false', () => {
const opts = {
configFile: false,
}

return cypress.run(opts)
.then(getStartArgs)
.then((args) => {
expect(args).to.deep.eq(opts)
})
})

it('rejects if project is an empty string', () => {
return expect(cypress.run({ project: '' })).to.be.rejected
})
Expand Down Expand Up @@ -223,15 +199,6 @@ describe('cypress', function () {
})
})

it('coerces --config-file false to boolean', async () => {
const args = 'cypress run --config-file false'.split(' ')
const options = await cypress.cli.parseRunArguments(args)

expect(options).to.deep.equal({
configFile: false,
})
})

it('coerces --config-file cypress.config.js to string', async () => {
const args = 'cypress run --config-file cypress.config.js'.split(' ')
const options = await cypress.cli.parseRunArguments(args)
Expand All @@ -241,15 +208,6 @@ describe('cypress', function () {
})
})

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)
Expand Down
15 changes: 5 additions & 10 deletions cli/test/lib/exec/open_spec.js
Expand Up @@ -56,15 +56,6 @@ describe('exec open', function () {
})
})

it('spawns with --config-file false', function () {
return open.start({ configFile: false })
.then(() => {
expect(spawn.start).to.be.calledWith(
['--config-file', false],
)
})
})

it('spawns with --config-file set', function () {
return open.start({ configFile: 'special-cypress.config.js' })
.then(() => {
Expand Down Expand Up @@ -142,7 +133,11 @@ describe('exec open', function () {
})

it('throws if --testing-type is invalid', () => {
expect(() => open.start({ testingType: 'randomTestingType' })).to.throw()
expect(() => open.processOpenOptions({ testingType: 'randomTestingType' })).to.throw()
})

it('throws if --config-file is false', () => {
expect(() => open.processOpenOptions({ configFile: 'false' })).to.throw()
})
})
})

0 comments on commit 74656d2

Please sign in to comment.