Skip to content

Commit 82f3522

Browse files
committed
test(e2e): always test against npm+pnpm+yarn
1 parent 1cfcdf8 commit 82f3522

File tree

2 files changed

+23
-39
lines changed

2 files changed

+23
-39
lines changed

.github/workflows/e2e-tests.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ jobs:
3535
cache: npm
3636
check-latest: true
3737

38-
- name: Cache verdaccio storage
39-
uses: actions/cache@v4
38+
- uses: pnpm/action-setup@v4
4039
with:
41-
path: ./.verdaccio-storage
42-
key: verdaccio-e2e-cli-${{ hashFiles('./package-lock.json') }}
40+
version: 10
4341

4442
- name: Install dependencies
4543
run: npm ci --no-audit
@@ -91,11 +89,9 @@ jobs:
9189
cache: npm
9290
check-latest: true
9391

94-
- name: Cache verdaccio storage
95-
uses: actions/cache@v4
92+
- uses: pnpm/action-setup@v4
9693
with:
97-
path: ./.verdaccio-storage
98-
key: verdaccio-e2e-cli-${{ hashFiles('./package-lock.json') }}
94+
version: 10
9995

10096
- name: Install dependencies
10197
run: npm ci --no-audit

e2e/install.e2e.ts

+19-31
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,6 @@ const itWithMockNpmRegistry = it.extend<{ registry: { address: string; cwd: stri
136136
},
137137
})
138138

139-
const doesPackageManagerExist = (packageManager: string): boolean => {
140-
try {
141-
execSync(`${packageManager} --version`)
142-
return true
143-
} catch {
144-
return false
145-
}
146-
}
147-
148139
const tests: [packageManager: string, config: { install: [cmd: string, args: string[]]; lockfile: string }][] = [
149140
[
150141
'npm',
@@ -170,29 +161,26 @@ const tests: [packageManager: string, config: { install: [cmd: string, args: str
170161
]
171162

172163
describe.each(tests)('%s → installs the cli and runs the help command without error', (packageManager, config) => {
173-
itWithMockNpmRegistry.runIf(doesPackageManagerExist(packageManager))(
174-
'installs the cli and runs the help command without error',
175-
async ({ registry }) => {
176-
const cwd = registry.cwd
177-
await execa(...config.install, {
178-
cwd,
179-
env: { npm_config_registry: registry.address },
180-
stdio: debug.enabled ? 'inherit' : 'ignore',
181-
})
164+
itWithMockNpmRegistry('installs the cli and runs the help command without error', async ({ registry }) => {
165+
const cwd = registry.cwd
166+
await execa(...config.install, {
167+
cwd,
168+
env: { npm_config_registry: registry.address },
169+
stdio: debug.enabled ? 'inherit' : 'ignore',
170+
})
182171

183-
expect(
184-
existsSync(path.join(cwd, config.lockfile)),
185-
`Generated lock file ${config.lockfile} does not exist in ${cwd}`,
186-
).toBe(true)
172+
expect(
173+
existsSync(path.join(cwd, config.lockfile)),
174+
`Generated lock file ${config.lockfile} does not exist in ${cwd}`,
175+
).toBe(true)
187176

188-
const binary = path.resolve(path.join(cwd, `./node_modules/.bin/netlify${platform() === 'win32' ? '.cmd' : ''}`))
189-
const { stdout } = await execa(binary, ['help'], { cwd })
177+
const binary = path.resolve(path.join(cwd, `./node_modules/.bin/netlify${platform() === 'win32' ? '.cmd' : ''}`))
178+
const { stdout } = await execa(binary, ['help'], { cwd })
190179

191-
expect(stdout.trim(), `Help command does not start with 'VERSION':\n\n${stdout}`).toMatch(/^VERSION/)
192-
expect(stdout, `Help command does not include 'netlify-cli/${pkg.version}':\n\n${stdout}`).toContain(
193-
`netlify-cli/${pkg.version}`,
194-
)
195-
expect(stdout, `Help command does not include '$ netlify [COMMAND]':\n\n${stdout}`).toMatch('$ netlify [COMMAND]')
196-
},
197-
)
180+
expect(stdout.trim(), `Help command does not start with 'VERSION':\n\n${stdout}`).toMatch(/^VERSION/)
181+
expect(stdout, `Help command does not include 'netlify-cli/${pkg.version}':\n\n${stdout}`).toContain(
182+
`netlify-cli/${pkg.version}`,
183+
)
184+
expect(stdout, `Help command does not include '$ netlify [COMMAND]':\n\n${stdout}`).toMatch('$ netlify [COMMAND]')
185+
})
198186
})

0 commit comments

Comments
 (0)