@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:
Steven Vachon
2020-03-03 18:12:52 -05:00
committed by GitHub
parent c3884abf62
commit ee5fcc03df
9 changed files with 289 additions and 31 deletions
@@ -0,0 +1,5 @@
#!/usr/bin/env node
import cli from '../cli/index';
cli();
+40
View File
@@ -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);
};