mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-25 10:19:30 -05:00
8dc94f3c53
* move to rollup
* no longer need to move some subdirs in start-build, special bin dir handling
* preserve modules so __dirname is properly resolved in spawn.ts
* ensure lib/exec/xvfb exports default
* make build processes more intuitive
* additional
* and
* fix clean
* fix tests
* revert
* rename clean cmd
* fix cjs exports
* fix test import
* fix tertiary dep bundling
* maybe..?
* ensure cli is built before tests are run
* exports= again
* discrete exports
* maybe if tslib is bundled
* add tslib as dependency for rollup
* lockfile, no longer bundle
* bundle tslib?
* cache
* preserve entry file paths in dist dir
* relative path change
* ensure the cjs entrypoint for the esm build of cli is available in dist
* properly import json so rollup picks it up
* ensure bin entrypoint has no file extension
* add exec/run.ts ? to entry files
* Revert "add exec/run.ts ? to entry files"
This reverts commit 8bb047a623.
* simplify rollup; make bin script +x on postbuild
* cleanup
* updates build docs
* fix ./bin export path
* comment to clarify why relative path resolution changed in spawn.ts
* make script start path (for dev mode) less brittle vis a vis build artifact location
* cleanup
* since we dont need monorepo packages yet, adding it here is premature
* externalize package.json to fix install script
* add entrypoints to cli knip config
* revert expected fixtures?
* use shelljs for win support
* some @types are prod dependencies, some are dev?
* rm unused script
* root build-prod script is actually unused
* resolve package.json dynamically from root
* look for pkg.name === cypress instead of a workspaces pkg
* correct buildinfo
* fix pkg undefined in info
* match both windows and nix path separators when matching for the binary entrypoint in rollup
* better error messaging for package.json not found
* fix curried fn
* Apply suggestion from @cacieprins
99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
// https://github.com/cypress-io/cypress/issues/316
|
|
import tmp from 'tmp'
|
|
import fs from 'fs-extra'
|
|
import openModule from './exec/open'
|
|
import runModule from './exec/run'
|
|
import util from './util'
|
|
import cliImport from './cli'
|
|
|
|
/**
|
|
* Opens Cypress GUI
|
|
* @see https://on.cypress.io/module-api#cypress-open
|
|
*/
|
|
export function open (options: any = {}): any {
|
|
options = util.normalizeModuleOptions(options)
|
|
|
|
return openModule.start(options)
|
|
}
|
|
|
|
/**
|
|
* Runs Cypress tests in the current project
|
|
* @see https://on.cypress.io/module-api#cypress-run
|
|
*/
|
|
export async function run (options: any = {}): Promise<any> {
|
|
if (!runModule.isValidProject(options.project)) {
|
|
throw new Error(`Invalid project path parameter: ${options.project}`)
|
|
}
|
|
|
|
options = util.normalizeModuleOptions(options)
|
|
tmp.setGracefulCleanup()
|
|
|
|
const outputPath: string = tmp.fileSync().name
|
|
|
|
options.outputPath = outputPath
|
|
|
|
const failedTests = await runModule.start(options)
|
|
const output = await fs.readJson(outputPath, { throws: false })
|
|
|
|
if (!output) {
|
|
return {
|
|
status: 'failed',
|
|
failures: failedTests,
|
|
message: 'Could not find Cypress test run results',
|
|
}
|
|
}
|
|
|
|
return output
|
|
}
|
|
|
|
export const cli = {
|
|
/**
|
|
* Parses CLI arguments into an object that you can pass to "cypress.run"
|
|
* @example
|
|
* const cypress = require('cypress')
|
|
* const cli = ['cypress', 'run', '--browser', 'firefox']
|
|
* const options = await cypress.cli.parseRunArguments(cli)
|
|
* // options is {browser: 'firefox'}
|
|
* await cypress.run(options)
|
|
* @see https://on.cypress.io/module-api
|
|
*/
|
|
parseRunArguments (args: string[]): any {
|
|
return cliImport.parseRunCommand(args)
|
|
},
|
|
}
|
|
|
|
/**
|
|
* Provides automatic code completion for configuration in many popular code editors.
|
|
* While it's not strictly necessary for Cypress to parse your configuration, we
|
|
* recommend wrapping your config object with `defineConfig()`
|
|
* @example
|
|
* module.exports = defineConfig({
|
|
* viewportWith: 400
|
|
* })
|
|
*
|
|
* @see ../types/cypress-npm-api.d.ts
|
|
* @param {Cypress.ConfigOptions} config
|
|
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
|
|
*/
|
|
export function defineConfig (config: any): any {
|
|
return config
|
|
}
|
|
|
|
/**
|
|
* Provides automatic code completion for Component Frameworks Definitions.
|
|
* While it's not strictly necessary for Cypress to parse your configuration, we
|
|
* recommend wrapping your Component Framework Definition object with `defineComponentFramework()`
|
|
* @example
|
|
* module.exports = defineComponentFramework({
|
|
* type: 'cypress-ct-solid-js'
|
|
* // ...
|
|
* })
|
|
*
|
|
* @see ../types/cypress-npm-api.d.ts
|
|
* @param {Cypress.ThirdPartyComponentFrameworkDefinition} config
|
|
* @returns {Cypress.ThirdPartyComponentFrameworkDefinition} the configuration passed in parameter
|
|
*/
|
|
export function defineComponentFramework (config: any): any {
|
|
return config
|
|
}
|