mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-17 04:29:57 -06:00
* chore: rename snapshots and spec files to fit vitest convention (#32405) * chore: move compiled files to dist directory to make vitest convertion easier (#32406) * chore: convert utils to vitest (#32407) * chore: convert logger to vitest * chore: convert errors spec to vitest * chore: convert cypress spec to vitest * chore: convert `exec` directory to `vitest` (#32428) * chore: cut over exec directory to vitest * Update cli/test/lib/exec/run.spec.ts * Update cli/test/lib/exec/run.spec.ts * Update cli/test/lib/exec/run.spec.ts * chore: convert the CLI and build script specs over to vitest (#32438) * chore: convert tasks directory to vitest (#32434) change way verify module is exported due to issues interpreting module (thinks its an esm) rework scripts as we cannot run an empty mocha suite chore: fix snapshots and verify requires that are internal to the cypress project fix stubbing issues with fs-extra which is also used by request-progress under the hood fix issues where xvfb was stopping prematurely * chore: remove files no longer used now that mocha tests are converted to vitest (#32455) * build binaries * chore: fix CLI tests (#32484) * chore: remove CI branch
108 lines
2.4 KiB
TypeScript
108 lines
2.4 KiB
TypeScript
import Debug from 'debug'
|
|
import util from '../util'
|
|
import spawn from './spawn'
|
|
import { start as verifyStart } from '../tasks/verify'
|
|
import { processTestingType, checkConfigFile } from './shared'
|
|
import { exitWithError } from '../errors'
|
|
|
|
const debug = Debug('cypress:cli')
|
|
|
|
/**
|
|
* Maps options collected by the CLI
|
|
* and forms list of CLI arguments to the server.
|
|
*
|
|
* Note: there is lightweight validation, with errors
|
|
* thrown synchronously.
|
|
*
|
|
* @returns {string[]} list of CLI arguments
|
|
*/
|
|
export const processOpenOptions = (options: any = {}): string[] => {
|
|
// In addition to setting the project directory, setting the project option
|
|
// here ultimately decides whether cypress is run in global mode or not.
|
|
// It's first based off whether it's installed globally by npm/yarn (-g).
|
|
// A global install can be overridden by the --project flag, putting Cypress
|
|
// in project mode. A non-global install can be overridden by the --global
|
|
// flag, putting it in global mode.
|
|
if (!util.isInstalledGlobally() && !options.global && !options.project) {
|
|
options.project = process.cwd()
|
|
}
|
|
|
|
const args: string[] = []
|
|
|
|
if (options.config) {
|
|
args.push('--config', options.config)
|
|
}
|
|
|
|
if (options.configFile !== undefined) {
|
|
checkConfigFile(options)
|
|
args.push('--config-file', options.configFile)
|
|
}
|
|
|
|
if (options.browser) {
|
|
args.push('--browser', options.browser)
|
|
}
|
|
|
|
if (options.env) {
|
|
args.push('--env', options.env)
|
|
}
|
|
|
|
if (options.port) {
|
|
args.push('--port', options.port)
|
|
}
|
|
|
|
if (options.project) {
|
|
args.push('--project', options.project)
|
|
}
|
|
|
|
if (options.global) {
|
|
args.push('--global', options.global)
|
|
}
|
|
|
|
if (options.inspect) {
|
|
args.push('--inspect')
|
|
}
|
|
|
|
if (options.inspectBrk) {
|
|
args.push('--inspectBrk')
|
|
}
|
|
|
|
args.push(...processTestingType(options))
|
|
|
|
debug('opening from options %j', options)
|
|
debug('command line arguments %j', args)
|
|
|
|
return args
|
|
}
|
|
|
|
export const start = async (options: any = {}): Promise<any> => {
|
|
function open (): any {
|
|
try {
|
|
const args = processOpenOptions(options)
|
|
|
|
return spawn.start(args, {
|
|
dev: options.dev,
|
|
detached: Boolean(options.detached),
|
|
})
|
|
} catch (err: any) {
|
|
if (err.details) {
|
|
return exitWithError(err.details)()
|
|
}
|
|
|
|
throw err
|
|
}
|
|
}
|
|
|
|
if (options.dev) {
|
|
return open()
|
|
}
|
|
|
|
await verifyStart()
|
|
|
|
return open()
|
|
}
|
|
|
|
export default {
|
|
start,
|
|
processOpenOptions,
|
|
}
|