Skip to content

Commit

Permalink
cli(e2e): add clean slate option
Browse files Browse the repository at this point in the history
- This allows to delete existing projects before running tests
  • Loading branch information
yannbf committed Sep 16, 2020
1 parent c5f58ef commit dc391b9
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions scripts/run-e2e.ts
Expand Up @@ -246,6 +246,7 @@ const runTests = async ({ name, version, ...rest }: Parameters) => {
cwd: path.join(siblingDir, `${name}-${version}`),
};

logger.log();
logger.info(`🏃‍♀️ Starting for ${name} ${version}`);
logger.log();
logger.debug(options);
Expand Down Expand Up @@ -298,14 +299,19 @@ const runTests = async ({ name, version, ...rest }: Parameters) => {
};

// Run tests!
const runE2E = (parameters: Parameters) =>
runTests(parameters)
const runE2E = async (parameters: Parameters) => {
const { name, version } = parameters;
const cwd = path.join(siblingDir, `${name}-${version}`);
if (startWithCleanSlate) {
logger.log();
logger.info(`♻️  Starting with a clean slate, removing existing ${name} folder`);
await cleanDirectory({ ...parameters, cwd });
}

return runTests(parameters)
.then(async () => {
if (!process.env.CI) {
const { name, version } = parameters;
const cwd = path.join(siblingDir, `${name}-${version}`);

const { cleanup } = await prompt({
const { cleanup } = await prompt<{ cleanup: boolean }>({
type: 'confirm',
name: 'cleanup',
message: 'Should perform cleanup?',
Expand All @@ -328,7 +334,9 @@ const runE2E = (parameters: Parameters) =>
logger.log();
process.exitCode = 1;
});
};

program.option('--clean', 'Clean up existing projects before running the tests', false);
program.option('--use-yarn-2', 'Run tests using Yarn 2 instead of Yarn 1 + npx', false);
program.option(
'--use-local-sb-cli',
Expand All @@ -337,7 +345,7 @@ program.option(
);
program.parse(process.argv);

const { useYarn2, useLocalSbCli, args: frameworkArgs } = program;
const { useYarn2, useLocalSbCli, clean: startWithCleanSlate, args: frameworkArgs } = program;

const typedConfigs: { [key: string]: Parameters } = configs;
let e2eConfigs: { [key: string]: Parameters } = {};
Expand Down

0 comments on commit dc391b9

Please sign in to comment.