From 14347586ac65f3ef13847d614196ea2481d8cc39 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Thu, 23 Nov 2023 18:23:32 +0100 Subject: [PATCH] fix: snapshot generation It looks like the addition of nightwatch broke the snapshot generation, as `nightwatch` was added to the deny list (correctly), but it means that the _only_ combinations that are filtered are the ones with the 3 e2e test libraries at the same time. We also need to filter out the combination of Cypress with Playwright, Cypress with Nightwatch, and Playwright with Nightwatch. See https://github.com/vuejs/create-vue-templates/ that currently includes cypress-playwright for example. This commit updates the script to remove all generated combinations, and to generate only the proper ones. --- scripts/snapshot.mjs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/snapshot.mjs b/scripts/snapshot.mjs index 6b0b9ff0..5e0224c2 100644 --- a/scripts/snapshot.mjs +++ b/scripts/snapshot.mjs @@ -17,7 +17,12 @@ const featureFlags = [ 'playwright', 'nightwatch' ] -const featureFlagsDenylist = [['cypress', 'playwright', 'nightwatch']] +const featureFlagsDenylist = [ + ['cypress', 'playwright'], + ['playwright', 'nightwatch'], + ['cypress', 'nightwatch'], + ['cypress', 'playwright', 'nightwatch'] +] // The following code & comments are generated by GitHub CoPilot. function fullCombination(arr) { @@ -51,12 +56,6 @@ function fullCombination(arr) { let flagCombinations = fullCombination(featureFlags) flagCombinations.push(['default']) -// Filter out combinations that are not allowed -flagCombinations = flagCombinations.filter( - (combination) => - !featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag))) -) - // `--with-tests` are equivalent of `--vitest --cypress` // Previously it means `--cypress` without `--vitest`. // Here we generate the snapshots only for the sake of easier comparison with older templates. @@ -70,14 +69,26 @@ withTestsFlags.push(['with-tests']) flagCombinations.push(...withTestsFlags) const playgroundDir = path.resolve(__dirname, '../playground/') -const bin = path.posix.relative('../playground/', '../outfile.cjs') - cd(playgroundDir) + +// remove all previous combinations for (const flags of flagCombinations) { const projectName = flags.join('-') console.log(`Removing previously generated project ${projectName}`) fs.rmSync(projectName, { recursive: true, force: true }) +} + +// Filter out combinations that are not allowed +flagCombinations = flagCombinations.filter( + (combination) => + !featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag))) +) + +const bin = path.posix.relative('../playground/', '../outfile.cjs') + +for (const flags of flagCombinations) { + const projectName = flags.join('-') console.log(`Creating project ${projectName}`) await $`node ${[bin, projectName, ...flags.map((flag) => `--${flag}`), '--force']}`