@grafana/e2e: added support for plugin repositories (#22546)
* Minor changes * Include Cypress support files in published package * Added CLI … with support for custom configurations (which Cypress does not currently support by default): * Loads cypress.json from @grafana/e2e as a base config (via a custom Cypress plugin) * Sets default values for project-level Cypress files (tests, etc) * Optionally loads a cypress.json from the current working directory as overrides * Updated lockfile
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import cli from '../cli/index';
|
||||
|
||||
cli();
|
||||
@@ -0,0 +1,40 @@
|
||||
import { resolve, sep } from 'path';
|
||||
import execa, { Options } from 'execa';
|
||||
import program from 'commander';
|
||||
|
||||
const cypress = (commandName: string) => {
|
||||
// Support running an unpublished dev build
|
||||
const parentPath = resolve(`${__dirname}/../`);
|
||||
const parentDirname = parentPath.split(sep).pop();
|
||||
const projectPath = resolve(`${parentPath}${parentDirname === 'dist' ? '/..' : ''}`);
|
||||
|
||||
const cypressOptions = [commandName, '--env', `CWD=${process.cwd()}`, `--project=${projectPath}`];
|
||||
|
||||
const execaOptions: Options = {
|
||||
cwd: __dirname,
|
||||
stdio: 'inherit',
|
||||
};
|
||||
|
||||
return execa(`${projectPath}/node_modules/.bin/cypress`, cypressOptions, execaOptions)
|
||||
.then(() => {}) // no return value
|
||||
.catch(error => console.error(error.message));
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const configOption = '-c, --config <path>';
|
||||
const configDescription = 'path to JSON file where configuration values are set; defaults to "cypress.json"';
|
||||
|
||||
program
|
||||
.command('open')
|
||||
.description('runs tests within the interactive GUI')
|
||||
.option(configOption, configDescription)
|
||||
.action(() => cypress('open'));
|
||||
|
||||
program
|
||||
.command('run')
|
||||
.description('runs tests from the CLI without the GUI')
|
||||
.option(configOption, configDescription)
|
||||
.action(() => cypress('run'));
|
||||
|
||||
program.parse(process.argv);
|
||||
};
|
||||
Reference in New Issue
Block a user