Skip to content

Commit c14cb10

Browse files
committed
test: stub posthog and clarify nock usage in setup-test-env
Generated-by: aiautocommit
1 parent ae1e4a2 commit c14cb10

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

web/test/setup-test-env.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import * as matchers from "@testing-library/jest-dom/matchers"
66
import "@testing-library/jest-dom/vitest"
77
import { cleanup } from "@testing-library/react"
88

9-
// without nock, posthog and other services will attempt to load and cause tests to be flakey
9+
// happy-dom blocks external <script src="..."> execution by default, which prevents SDK bundles
10+
// like PostHog/Clerk from loading in tests.
11+
//
12+
// nock is still useful as a second layer: it blocks accidental external HTTP calls (fetch/xhr/http)
13+
// so tests remain deterministic even if runtime behavior changes.
1014
nock.disableNetConnect()
1115
nock.enableNetConnect((host: string) => {
1216
return host.startsWith("127.0.0.1") || host.startsWith("localhost")
1317
})
1418

19+
// Keep this explicit PostHog stub for stability across environment/runtime differences.
1520
nock(/posthog\.com/)
1621
.persist()
1722
.get(/.*/)

0 commit comments

Comments
 (0)