From fc269ed78d0af781efaffa55c351c8f5a801fa2c Mon Sep 17 00:00:00 2001 From: T <6601329+cookesan@users.noreply.github.com> Date: Mon, 29 Jun 2026 11:44:35 -0300 Subject: [PATCH] chore: skip package manager tests when binaries are missing (#2441) Co-authored-by: Aaron --- .../package-managers/__tests__/pnpm.test.ts | 3 ++- .../package-managers/__tests__/yarn.test.ts | 3 ++- packages/wxt/src/core/utils/testing/fixtures.ts | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 packages/wxt/src/core/utils/testing/fixtures.ts diff --git a/packages/wxt/src/core/package-managers/__tests__/pnpm.test.ts b/packages/wxt/src/core/package-managers/__tests__/pnpm.test.ts index ab05424d..cf4d13d4 100644 --- a/packages/wxt/src/core/package-managers/__tests__/pnpm.test.ts +++ b/packages/wxt/src/core/package-managers/__tests__/pnpm.test.ts @@ -2,10 +2,11 @@ import spawn from 'nano-spawn'; import path from 'node:path'; import { beforeAll, describe, expect, it } from 'vitest'; import { pnpm } from '../pnpm'; +import { describeWithBin } from '../../utils/testing/fixtures'; process.env.WXT_PNPM_IGNORE_WORKSPACE = 'true'; -describe('PNPM Package Management Utils', () => { +describeWithBin('pnpm', 'PNPM Package Management Utils', () => { describe('listDependencies', () => { const cwd = path.resolve(__dirname, 'fixtures/simple-pnpm-project'); diff --git a/packages/wxt/src/core/package-managers/__tests__/yarn.test.ts b/packages/wxt/src/core/package-managers/__tests__/yarn.test.ts index 40415b7d..68654900 100644 --- a/packages/wxt/src/core/package-managers/__tests__/yarn.test.ts +++ b/packages/wxt/src/core/package-managers/__tests__/yarn.test.ts @@ -1,8 +1,9 @@ import { describe, expect, it } from 'vitest'; import path from 'node:path'; import { yarn } from '../yarn'; +import { describeWithBin } from '../../utils/testing/fixtures'; -describe('Yarn Package Management Utils', () => { +describeWithBin('yarn', 'Yarn Package Management Utils', () => { describe('listDependencies', () => { const cwd = path.resolve(__dirname, 'fixtures/simple-yarn-project'); diff --git a/packages/wxt/src/core/utils/testing/fixtures.ts b/packages/wxt/src/core/utils/testing/fixtures.ts new file mode 100644 index 00000000..9d233390 --- /dev/null +++ b/packages/wxt/src/core/utils/testing/fixtures.ts @@ -0,0 +1,17 @@ +import { spawnSync } from 'node:child_process'; +import { describe } from 'vitest'; + +export function describeWithBin( + bin: string, + title: string, + callback: () => void, +) { + if (process.env.CI === 'true') return describe(title, callback); + + const result = spawnSync(bin, ['--version'], { + stdio: 'ignore', + shell: true, + }); + if (result.status !== 0) return describe.skip(title, callback); + return describe(title, callback); +}