Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3756801

Browse filesBrowse files
committed
test: check most possible combination of CNA flags
1 parent 9a72ad6 commit 3756801
Copy full SHA for 3756801

File tree

1 file changed

+77
-0
lines changed
Filter options

1 file changed

+77
-0
lines changed
+77Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {
2+
createNextApp,
3+
spawnExitPromise,
4+
tryNextDev,
5+
useTempDir,
6+
} from '../utils'
7+
8+
let testVersion
9+
beforeAll(async () => {
10+
if (testVersion) return
11+
// TODO: investigate moving this post publish or create deployed GH#57025
12+
// tarballs to avoid these failing while a publish is in progress
13+
testVersion = 'latest'
14+
// const span = new Span({ name: 'parent' })
15+
// testVersion = (
16+
// await createNextInstall({ onlyPackages: true, parentSpan: span })
17+
// ).get('next')
18+
})
19+
20+
describe.each(['app', 'pages'] as const)(
21+
'CNA options matrix - %s',
22+
(pagesOrApp) => {
23+
const allFlagValues = {
24+
app: [pagesOrApp === 'app' ? '--app' : '--no-app'],
25+
ts: ['--js', '--ts'],
26+
importAlias: [
27+
'--import-alias=@acme/*',
28+
'--import-alias=@/*',
29+
'--no-import-alias',
30+
],
31+
// doesn't affect if the app builds or not
32+
// eslint: ['--eslint', '--no-eslint'],
33+
eslint: ['--eslint'],
34+
srcDir: ['--src-dir', '--no-src-dir'],
35+
tailwind: ['--tailwind', '--no-tailwind'],
36+
// shouldn't affect if the app builds or not
37+
// packageManager: ['--use-npm', '--use-pnpm', '--use-yarn', '--use-bun'],
38+
}
39+
40+
const getPermutations = <T>(items: T[][]): T[][] => {
41+
if (!items.length) return [[]]
42+
const [first, ...rest] = items
43+
const children = getPermutations(rest)
44+
return first.flatMap((value) =>
45+
children.map((child) => [value, ...child])
46+
)
47+
}
48+
49+
const flagPermutations = getPermutations(Object.values(allFlagValues))
50+
const testCases = flagPermutations.map((flags) => ({
51+
name: flags.join(' '),
52+
flags,
53+
}))
54+
55+
let id = 0
56+
it.each(testCases)('$name', async ({ flags }) => {
57+
await useTempDir(async (cwd) => {
58+
const projectName = `cna-matrix-${pagesOrApp}-${id++}`
59+
const childProcess = createNextApp(
60+
[projectName, ...flags],
61+
{
62+
cwd,
63+
},
64+
testVersion
65+
)
66+
67+
const exitCode = await spawnExitPromise(childProcess)
68+
expect(exitCode).toBe(0)
69+
70+
await tryNextDev({
71+
cwd,
72+
projectName,
73+
})
74+
})
75+
})
76+
}
77+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.