grafana/packages/grafana-e2e/cli.js
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

50 lines
1.5 KiB
JavaScript

const { program } = require('commander');
const execa = require('execa');
const { resolve, sep } = require('path');
const resolveBin = require('resolve-as-bin');
const cypress = (commandName, { updateScreenshots }) => {
// 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}`];
const execaOptions = {
cwd: __dirname,
stdio: 'inherit',
};
return execa(resolveBin('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';
program
.command('open')
.description('runs tests within the interactive GUI')
.option(updateOption, updateDescription)
.action((options) => cypress('open', options));
program
.command('run')
.description('runs tests from the CLI without the GUI')
.option(updateOption, updateDescription)
.action((options) => cypress('run', options));
program.parse(process.argv);
};