test(sdk-ts): make factories extension path assertions portable to Windows
why
5 tests in packages/sdk-ts/tests/browser/factories.test.ts fail deterministically on Windows (pnpm vitest run packages/sdk-ts/tests/browser/factories.test.ts → 5 failed | 75 passed):
launches a local browser and prepares the packaged extensionignores local connect extension ID undefined/ ``(empty) /installed-stagehand/wrong-id
The assertions match the packaged extension directory with the POSIX-only substring "dist/extension":
extensionDir: expect.stringContaining("dist/extension") as string,
localExtensionDir: expect.stringContaining("dist/extension"),
but the value under test is STAGEHAND_EXTENSION_DIRECTORY_PATH (packages/sdk-ts/src/extensionAssets.ts):
fileURLToPath(new URL("dist/extension/", packageRoot))
which on Windows resolves to a backslashed path such as D:\repo\packages\sdk-ts\dist\extension\. It never contains the literal substring dist/extension, so the expect.objectContaining checks fail on every Windows run (vitest 4, Node 24).
what changed
Test-only, one file (packages/sdk-ts/tests/browser/factories.test.ts):
- Match with
path.join("dist", "extension")instead of the hardcoded POSIX substring. On POSIX this is the samedist/extensionstring as before; on Windows it becomesdist\extension, matching the actual value. No assertions are weakened, no product code is touched. - No Changeset added: per CONTRIBUTING.md, test-only changes do not need one.
test plan
Windows 10 (10.0.26200), Node v24.19.0, pnpm 11.21.0, vitest 4.1.12, upstream main @ 6f2686d792b7f5836b04754e0f6a44db39928592:
- Before:
pnpm vitest run packages/sdk-ts/tests/browser/factories.test.ts→5 failed | 75 passed(red) - After: same command →
80 passed (80)(green); identical command is green on POSIX sincepath.joinreduces to the original substring there - Full sdk-ts unit suite after the fix (
pnpm vitest run packages/sdk-ts/tests --exclude=packages/sdk-ts/tests/browser-runtime/**):616 passed | 4 failed— the 4 remaining failures are pre-existing, unrelated Windows issues in other files (browserbaseTransport fake-timer assertion, objectWrapperutimesnegative-mtime fixture, packageContractspawn pnpm ENOENT, localBrowser Chrome discovery) and are intentionally not bundled here pnpm exec oxfmt --check <file>clean;pnpm exec oxlint <file>0 errors (8 pre-existing warnings unchanged);npx tsc --noEmit -p tsconfig.json(sdk-ts, tests included) clean;git diff --checkclean
AI assistance
Disclosure: this fix was identified and prepared with the help of an AI coding agent (ZCode). The failing-test reproduction, root-cause analysis, patch, and validation logs were all produced/verified locally against upstream main (6f2686d); the diff above is the complete change.
Summary by cubic
Makes the extension path assertions in packages/sdk-ts/tests/browser/factories.test.ts portable to Windows, fixing 5 tests that failed on every Windows run. The assertions matched the hardcoded POSIX substring "dist/extension", but fileURLToPath produces backslashed paths on Windows; they now use path.join("dist", "extension"), which resolves to the same string on POSIX and the backslashed form on Windows without weakening any checks. Test-only change, no product code touched.