Skip to content

Commit 5ba8f64

Browse files
authored
fix: snapshot generation (#383)
1 parent b5ae765 commit 5ba8f64

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

scripts/snapshot.mjs

+20-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ const featureFlags = [
1717
'playwright',
1818
'nightwatch'
1919
]
20-
const featureFlagsDenylist = [['cypress', 'playwright', 'nightwatch']]
20+
const featureFlagsDenylist = [
21+
['cypress', 'playwright'],
22+
['playwright', 'nightwatch'],
23+
['cypress', 'nightwatch'],
24+
['cypress', 'playwright', 'nightwatch']
25+
]
2126

2227
// The following code & comments are generated by GitHub CoPilot.
2328
function fullCombination(arr) {
@@ -51,12 +56,6 @@ function fullCombination(arr) {
5156
let flagCombinations = fullCombination(featureFlags)
5257
flagCombinations.push(['default'])
5358

54-
// Filter out combinations that are not allowed
55-
flagCombinations = flagCombinations.filter(
56-
(combination) =>
57-
!featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag)))
58-
)
59-
6059
// `--with-tests` are equivalent of `--vitest --cypress`
6160
// Previously it means `--cypress` without `--vitest`.
6261
// Here we generate the snapshots only for the sake of easier comparison with older templates.
@@ -70,14 +69,26 @@ withTestsFlags.push(['with-tests'])
7069
flagCombinations.push(...withTestsFlags)
7170

7271
const playgroundDir = path.resolve(__dirname, '../playground/')
73-
const bin = path.posix.relative('../playground/', '../outfile.cjs')
74-
7572
cd(playgroundDir)
73+
74+
// remove all previous combinations
7675
for (const flags of flagCombinations) {
7776
const projectName = flags.join('-')
7877

7978
console.log(`Removing previously generated project ${projectName}`)
8079
fs.rmSync(projectName, { recursive: true, force: true })
80+
}
81+
82+
// Filter out combinations that are not allowed
83+
flagCombinations = flagCombinations.filter(
84+
(combination) =>
85+
!featureFlagsDenylist.some((denylist) => denylist.every((flag) => combination.includes(flag)))
86+
)
87+
88+
const bin = path.posix.relative('../playground/', '../outfile.cjs')
89+
90+
for (const flags of flagCombinations) {
91+
const projectName = flags.join('-')
8192

8293
console.log(`Creating project ${projectName}`)
8394
await $`node ${[bin, projectName, ...flags.map((flag) => `--${flag}`), '--force']}`

0 commit comments

Comments
 (0)