cypress
Version:
Cypress is a next generation front end testing tool built for the modern web
105 lines (100 loc) • 3.36 kB
JavaScript
;
var xvfb = require('./xvfb-Csr_YzMk.js');
var tmp = require('tmp');
var fs = require('fs-extra');
var cli$1 = require('./cli-CQHngRhO.js');
/**
* Opens Cypress GUI
* @see https://on.cypress.io/module-api#cypress-open
*/
function open(options = {}) {
options = xvfb.util.normalizeModuleOptions(options);
return cli$1.openModule.start(options);
}
/**
* Runs Cypress tests in the current project
* @see https://on.cypress.io/module-api#cypress-run
*/
function run() {
return xvfb.__awaiter(this, arguments, void 0, function* (options = {}) {
if (!cli$1.runModule.isValidProject(options.project)) {
throw new Error(`Invalid project path parameter: ${options.project}`);
}
options = xvfb.util.normalizeModuleOptions(options);
tmp.setGracefulCleanup();
const outputPath = tmp.fileSync().name;
options.outputPath = outputPath;
const failedTests = yield cli$1.runModule.start(options);
const output = yield fs.readJson(outputPath, { throws: false });
if (!output) {
return {
status: 'failed',
failures: failedTests,
message: 'Could not find Cypress test run results',
};
}
return output;
});
}
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) {
return cli$1.cliModule.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
*/
function defineConfig(config) {
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
*/
function defineComponentFramework(config) {
return config;
}
var cypress = /*#__PURE__*/Object.freeze({
__proto__: null,
cli: cli,
defineComponentFramework: defineComponentFramework,
defineConfig: defineConfig,
open: open,
run: run
});
exports.cli = cli;
exports.cypress = cypress;
exports.defineComponentFramework = defineComponentFramework;
exports.defineConfig = defineConfig;
exports.open = open;
exports.run = run;