Skip to content

Commit c57cccb

Browse files
committed
test(e2e): always test against npm+pnpm+yarn
1 parent d7c1547 commit c57cccb

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
@@ -36,11 +36,9 @@ jobs:
3636
cache: npm
3737
check-latest: true
3838

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

4543
- name: Install dependencies
4644
run: npm ci --no-audit
@@ -92,11 +90,9 @@ jobs:
9290
cache: npm
9391
check-latest: true
9492

95-
- name: Cache verdaccio storage
96-
uses: actions/cache@v4
93+
- uses: pnpm/action-setup@v4
9794
with:
98-
path: ./.verdaccio-storage
99-
key: verdaccio-e2e-cli-${{ hashFiles('./package-lock.json') }}
95+
version: 10
10096

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

e2e/install.e2e.ts

+19-31
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,6 @@ const itWithMockNpmRegistry = it.extend<{ registry: { address: string; cwd: stri
140140
},
141141
})
142142

143-
const doesPackageManagerExist = (packageManager: string): boolean => {
144-
try {
145-
execSync(`${packageManager} --version`)
146-
return true
147-
} catch {
148-
return false
149-
}
150-
}
151-
152143
const tests: [packageManager: string, config: { install: [cmd: string, args: string[]]; lockfile: string }][] = [
153144
[
154145
'npm',
@@ -174,29 +165,26 @@ const tests: [packageManager: string, config: { install: [cmd: string, args: str
174165
]
175166

176167
describe.each(tests)('%s → installs the cli and runs the help command without error', (packageManager, config) => {
177-
itWithMockNpmRegistry.runIf(doesPackageManagerExist(packageManager))(
178-
'installs the cli and runs the help command without error',
179-
async ({ registry }) => {
180-
const cwd = registry.cwd
181-
await execa(...config.install, {
182-
cwd,
183-
env: { npm_config_registry: registry.address },
184-
stdio: debug.enabled ? 'inherit' : 'ignore',
185-
})
168+
itWithMockNpmRegistry('installs the cli and runs the help command without error', async ({ registry }) => {
169+
const cwd = registry.cwd
170+
await execa(...config.install, {
171+
cwd,
172+
env: { npm_config_registry: registry.address },
173+
stdio: debug.enabled ? 'inherit' : 'ignore',
174+
})
186175

187-
expect(
188-
existsSync(path.join(cwd, config.lockfile)),
189-
`Generated lock file ${config.lockfile} does not exist in ${cwd}`,
190-
).toBe(true)
176+
expect(
177+
existsSync(path.join(cwd, config.lockfile)),
178+
`Generated lock file ${config.lockfile} does not exist in ${cwd}`,
179+
).toBe(true)
191180

192-
const binary = path.resolve(path.join(cwd, `./node_modules/.bin/netlify${platform() === 'win32' ? '.cmd' : ''}`))
193-
const { stdout } = await execa(binary, ['help'], { cwd })
181+
const binary = path.resolve(path.join(cwd, `./node_modules/.bin/netlify${platform() === 'win32' ? '.cmd' : ''}`))
182+
const { stdout } = await execa(binary, ['help'], { cwd })
194183

195-
expect(stdout.trim(), `Help command does not start with 'VERSION':\n\n${stdout}`).toMatch(/^VERSION/)
196-
expect(stdout, `Help command does not include 'netlify-cli/${pkg.version}':\n\n${stdout}`).toContain(
197-
`netlify-cli/${pkg.version}`,
198-
)
199-
expect(stdout, `Help command does not include '$ netlify [COMMAND]':\n\n${stdout}`).toMatch('$ netlify [COMMAND]')
200-
},
201-
)
184+
expect(stdout.trim(), `Help command does not start with 'VERSION':\n\n${stdout}`).toMatch(/^VERSION/)
185+
expect(stdout, `Help command does not include 'netlify-cli/${pkg.version}':\n\n${stdout}`).toContain(
186+
`netlify-cli/${pkg.version}`,
187+
)
188+
expect(stdout, `Help command does not include '$ netlify [COMMAND]':\n\n${stdout}`).toMatch('$ netlify [COMMAND]')
189+
})
202190
})

0 commit comments

Comments
 (0)