diff --git a/lib/src/host/git-info.test.ts b/lib/src/host/git-info.test.ts index 675fd7b2b..69705402b 100644 --- a/lib/src/host/git-info.test.ts +++ b/lib/src/host/git-info.test.ts @@ -88,7 +88,8 @@ describe('gitInfo', () => { it('hands git the canonical path, never the symlink it was given', async () => { const link = join(root, 'link-to-src'); - symlinkSync(join(root, 'myrepo/src'), link); + // A directory junction exercises realpath without Windows symlink privileges. + symlinkSync(join(root, 'myrepo/src'), link, process.platform === 'win32' ? 'junction' : 'dir'); spawned.length = 0; expect((await gitInfo([link]))[link]).toEqual({ repo: 'myrepo', branch: 'main' }); const dirs = spawned.map((args) => args[args.indexOf('-C') + 1]); diff --git a/lib/src/host/playwright-install.test.ts b/lib/src/host/playwright-install.test.ts index 273474ed0..b4d697959 100644 --- a/lib/src/host/playwright-install.test.ts +++ b/lib/src/host/playwright-install.test.ts @@ -1,6 +1,6 @@ // @vitest-environment node import { afterEach, beforeEach, expect, test } from 'vitest'; -import { mkdirSync, mkdtempSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'; +import { mkdirSync, mkdtempSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { resolvePlaywrightInstall } from './playwright-install'; @@ -25,7 +25,10 @@ function write(file: string, text: string): string { function link(target: string, at: string): void { mkdirSync(path.dirname(at), { recursive: true }); - symlinkSync(target, at); + // Windows package managers use directory junctions without symlink privileges. + // File links stay real symlinks for the POSIX launcher layouts. + const directory = statSync(path.resolve(path.dirname(at), target)).isDirectory(); + symlinkSync(target, at, process.platform === 'win32' && directory ? 'junction' : undefined); } function cliPackage(dir: string, bin = 'playwright-cli.js'): void {