The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/packages/grafana-e2e/cli.js

57 lines
1.8 KiB

const { program } = require('commander');
const execa = require('execa');
const { resolve, sep } = require('path');
const resolveBin = require('resolve-bin');
const cypress = (commandName, { updateScreenshots, browser }) => {
// Support running an unpublished dev build
const dirname = __dirname.split(sep).pop();
const projectPath = resolve(`${__dirname}${dirname === 'dist' ? '/..' : ''}`);
// 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}`];
if (browser) {
cypressOptions.push('--browser', browser);
}
const execaOptions = {
cwd: __dirname,
stdio: 'inherit',
};
return execa(resolveBin.sync('cypress'), cypressOptions, execaOptions)
.then(() => {}) // no return value
.catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
};
module.exports = () => {
const updateOption = '-u, --update-screenshots';
const updateDescription = 'update expected screenshots';
const browserOption = '-b, --browser <browser>';
const browserDescription = 'specify which browser to use';
program
.command('open')
.description('runs tests within the interactive GUI')
.option(updateOption, updateDescription)
.option(browserOption, browserDescription)
.action((options) => cypress('open', options));
program
.command('run')
.description('runs tests from the CLI without the GUI')
.option(updateOption, updateDescription)
.option(browserOption, browserDescription)
.action((options) => cypress('run', options));
program.parse(process.argv);
};