@grafana/e2e: screenshots and panel flow (#25203)

* Cleanup

* addPanel now supports (optional) custom dashboardUid

* addPanel now supports (optional) visualization name

* Added CLI option for updating screenshot fixtures

* Added support for console.* functions within tests

* Refactored screenshot command for greater simplicity

* addPanel now sets a unique title

* Updated lockfile
This commit is contained in:
Steven Vachon
2020-06-01 08:48:23 -04:00
committed by GitHub
parent 01ecbae2ee
commit 78febbbeef
10 changed files with 145 additions and 79 deletions

View File

@ -3,12 +3,18 @@ const program = require('commander');
const resolveBin = require('resolve-as-bin');
const { resolve, sep } = require('path');
const cypress = commandName => {
const cypress = (commandName, { updateScreenshots }) => {
// Support running an unpublished dev build
const dirname = __dirname.split(sep).pop();
const projectPath = resolve(`${__dirname}${dirname === 'dist' ? '/..' : ''}`);
const cypressOptions = [commandName, '--env', `CWD=${process.cwd()}`, `--project=${projectPath}`];
// For plugins/extendConfig
const CWD = `CWD=${process.cwd()}`;
// For plugins/compareSnapshots
const UPDATE_SCREENSHOTS = `UPDATE_SCREENSHOTS=${updateScreenshots ? 1 : 0}`;
const cypressOptions = [commandName, '--env', `${CWD},${UPDATE_SCREENSHOTS}`, `--project=${projectPath}`];
const execaOptions = {
cwd: __dirname,
@ -24,20 +30,20 @@ const cypress = commandName => {
};
module.exports = () => {
const configOption = '-c, --config <path>';
const configDescription = 'path to JSON file where configuration values are set; defaults to "cypress.json"';
const updateOption = '-u, --update-screenshots';
const updateDescription = 'update expected screenshots';
program
.command('open')
.description('runs tests within the interactive GUI')
.option(configOption, configDescription)
.action(() => cypress('open'));
.option(updateOption, updateDescription)
.action(options => cypress('open', options));
program
.command('run')
.description('runs tests from the CLI without the GUI')
.option(configOption, configDescription)
.action(() => cypress('run'));
.option(updateOption, updateDescription)
.action(options => cypress('run', options));
program.parse(process.argv);
};