Skip to content

Commit b3f93bc

Browse files
committed
fix(test): use itUnixOnly for the git-clone fetcher test
Switch the raw it.skipIf(WIN32) to the itUnixOnly helper so the skip reason lives in the helper name (satisfies socket/prefer-windows-test-helpers), and extend itUnixOnly to forward an optional timeout for the 120s git-clone case.
1 parent 34213b3 commit b3f93bc

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

test/unit/packages/operations.network.test.mts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ import { existsSync, promises as fs } from 'node:fs'
1212
import { createRequire } from 'node:module'
1313
import path from 'node:path'
1414

15-
import { WIN32 } from '../../../src/constants/platform'
1615
import { extractPackage, packPackage } from '../../../src/packages/tarball'
1716
import type { ExtractOptions } from '../../../src/packages/types'
1817
import { normalizePath } from '../../../src/paths/normalize'
1918
import { expect, it } from 'vitest'
20-
import { describeNetworkOnly } from '../util/skip-helpers'
19+
import { describeNetworkOnly, itUnixOnly } from '../util/skip-helpers'
2120
import { runWithTempDir } from '../util/temp-file-helper'
2221
import { tolerantTimeout } from '../../_shared/fleet/lib/timing.mts'
2322

@@ -299,13 +298,13 @@ describeNetworkOnly('pacote fetcher coverage', () => {
299298
tolerantTimeout(60_000),
300299
)
301300

302-
// Skipped on Windows: the GitHub Actions windows runner's git is configured
303-
// to rewrite github.com HTTPS urls to SSH (an `insteadOf` rule), so both the
304-
// `github:` shorthand and an explicit `git+https://…` spec resolve to
305-
// git@github.com:… and fail with "Permission denied (publickey)" — the runner
306-
// has no SSH key. The GitFetcher path is identical across platforms, so the
307-
// unix lanes cover it; there's no Windows-specific code to exercise here.
308-
it.skipIf(WIN32)(
301+
// Unix-only: the GitHub Actions windows runner's git is configured to rewrite
302+
// github.com HTTPS urls to SSH (an `insteadOf` rule), so both the `github:`
303+
// shorthand and an explicit `git+https://…` spec resolve to git@github.com:…
304+
// and fail with "Permission denied (publickey)" — the runner has no SSH key.
305+
// The GitFetcher path is identical across platforms, so the unix lanes cover
306+
// it; there's no Windows-specific code to exercise here.
307+
itUnixOnly(
309308
'git specs use pacote/lib/git.js + @npmcli/git',
310309
async () => {
311310
// Git archives are fetched via pacote/lib/git.js which wraps

test/unit/util/skip-helpers.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ export function itRequires(
105105
}
106106

107107
/**
108-
* Test that only runs on Unix-likes (Linux, macOS). Skipped on Windows.
108+
* Test that only runs on Unix-likes (Linux, macOS). Skipped on Windows. An
109+
* optional `timeout` (ms) is forwarded to vitest for long-running cases.
109110
*/
110-
export function itUnixOnly(name: string, fn: TestFn): void {
111-
it.skipIf(WIN32)(tagged(name, TAG_UNIX), fn)
111+
export function itUnixOnly(
112+
name: string,
113+
fn: TestFn,
114+
timeout?: number | undefined,
115+
): void {
116+
it.skipIf(WIN32)(tagged(name, TAG_UNIX), fn, timeout)
112117
}
113118

114119
/**

0 commit comments

Comments
 (0)