Skip to content

Commit 5820942

Browse files
authored
fix(core): remove testing export from posthog-core (#2370)
1 parent 9fb0e84 commit 5820942

File tree

9 files changed

+78
-57
lines changed

9 files changed

+78
-57
lines changed

.changeset/early-carrots-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@posthog/core': patch
3+
---
4+
5+
remove testing export

.changeset/itchy-keys-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'posthog-node': patch
3+
---
4+
5+
remove testing from posthog-core

packages/core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"files": [
1414
"dist",
15-
"src"
15+
"src",
16+
"!src/__tests__"
1617
],
1718
"scripts": {
1819
"clean": "rimraf dist",

packages/core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export { getFeatureFlagValue } from './featureFlagUtils'
22
export * from './utils'
33
export * as ErrorTracking from './error-tracking'
44
export { uuidv7 } from './vendor/uuidv7'
5-
export * as testing from './testing'
65
export * from './posthog-core'
76
export * from './posthog-core-stateless'
87
export * from './types'

packages/node/src/__tests__/extensions/sentry-integration.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PostHog } from '@/entrypoints/index.node'
22
import { PostHogSentryIntegration } from '@/extensions/sentry-integration'
3-
import { testing } from '@posthog/core'
3+
import { waitForPromises } from '../utils'
44

55
jest.mock('../../version', () => ({ version: '1.2.3' }))
66

@@ -108,9 +108,9 @@ describe('PostHogSentryIntegration', () => {
108108

109109
processorFunction(createMockSentryException())
110110

111-
await testing.waitForPromises() // First flush
111+
await waitForPromises() // First flush
112112
jest.runOnlyPendingTimers() // Flush timer
113-
await testing.waitForPromises() // Second flush
113+
await waitForPromises() // Second flush
114114
const batchEvents = getLastBatchEvents()
115115

116116
expect(batchEvents).toEqual([

packages/node/src/__tests__/feature-flags.flags.spec.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PostHog } from '@/entrypoints/index.node'
22
import { PostHogOptions } from '@/types'
3-
import { apiImplementation, apiImplementationV4 } from './utils'
4-
import { testing } from '@posthog/core'
3+
import { apiImplementation, apiImplementationV4, waitForPromises } from './utils'
54
import { PostHogV2FlagsResponse } from '@posthog/core'
65

76
jest.spyOn(console, 'debug').mockImplementation()
@@ -36,7 +35,7 @@ describe('flags v2', () => {
3635
expect(result).toBe(undefined)
3736
expect(mockedFetch).toHaveBeenCalledWith('http://example.com/flags/?v=2&config=true', expect.any(Object))
3837

39-
await testing.waitForPromises()
38+
await waitForPromises()
4039
expect(capturedMessage).toMatchObject({
4140
distinct_id: 'some-distinct-id',
4241
event: '$feature_flag_called',
@@ -150,7 +149,7 @@ describe('flags v2', () => {
150149
expect(result).toBe(expectedResponse)
151150
expect(mockedFetch).toHaveBeenCalledWith('http://example.com/flags/?v=2&config=true', expect.any(Object))
152151

153-
await testing.waitForPromises()
152+
await waitForPromises()
154153
expect(capturedMessage).toMatchObject({
155154
distinct_id: 'some-distinct-id',
156155
event: '$feature_flag_called',
@@ -213,7 +212,7 @@ describe('flags v2', () => {
213212
expect(result).toEqual([0, 1, 2])
214213
expect(mockedFetch).toHaveBeenCalledWith('http://example.com/flags/?v=2&config=true', expect.any(Object))
215214

216-
await testing.waitForPromises()
215+
await waitForPromises()
217216
expect(capturedMessage).toBeUndefined()
218217
})
219218
})
@@ -300,7 +299,7 @@ describe('flags v2', () => {
300299
})
301300

302301
await posthog.getFeatureFlag('error-flag', 'some-distinct-id')
303-
await testing.waitForPromises()
302+
await waitForPromises()
304303
expect(capturedMessage).toBeUndefined()
305304
})
306305
})
@@ -326,7 +325,7 @@ describe('flags v1', () => {
326325
expect(result).toBe(undefined)
327326
expect(mockedFetch).toHaveBeenCalledWith('http://example.com/flags/?v=2&config=true', expect.any(Object))
328327

329-
await testing.waitForPromises()
328+
await waitForPromises()
330329
expect(capturedMessage).toMatchObject({
331330
distinct_id: 'some-distinct-id',
332331
event: '$feature_flag_called',
@@ -372,7 +371,7 @@ describe('flags v1', () => {
372371
expect(result).toEqual([0, 1, 2])
373372
expect(mockedFetch).toHaveBeenCalledWith('http://example.com/flags/?v=2&config=true', expect.any(Object))
374373

375-
await testing.waitForPromises()
374+
await waitForPromises()
376375
expect(capturedMessage).toBeUndefined()
377376
})
378377
})

packages/node/src/__tests__/feature-flags.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
InconclusiveMatchError,
66
relativeDateParseForFeatureFlagMatching,
77
} from '@/extensions/feature-flags/feature-flags'
8-
import { anyFlagsCall, anyLocalEvalCall, apiImplementation } from './utils'
9-
import { testing } from '@posthog/core'
8+
import { anyFlagsCall, anyLocalEvalCall, apiImplementation, waitForPromises } from './utils'
109

1110
jest.spyOn(console, 'debug').mockImplementation()
1211

@@ -1900,7 +1899,7 @@ describe('local evaluation', () => {
19001899
posthog.on('localEvaluationFlagsLoaded', eventHandler)
19011900

19021901
// Wait for initial load
1903-
await testing.waitForPromises()
1902+
await waitForPromises()
19041903

19051904
expect(eventHandler).toHaveBeenCalledWith(2) // Should be called with number of flags loaded
19061905
})
@@ -1920,7 +1919,7 @@ describe('local evaluation', () => {
19201919
posthog.on('localEvaluationFlagsLoaded', eventHandler)
19211920

19221921
// Wait for initial load
1923-
await testing.waitForPromises()
1922+
await waitForPromises()
19241923

19251924
expect(eventHandler).not.toHaveBeenCalled()
19261925
})
@@ -1956,7 +1955,7 @@ describe('local evaluation', () => {
19561955
posthog.on('localEvaluationFlagsLoaded', eventHandler)
19571956

19581957
// Wait for initial load
1959-
await testing.waitForPromises()
1958+
await waitForPromises()
19601959
eventHandler.mockClear() // Clear initial call
19611960

19621961
// Reload flags
@@ -2021,7 +2020,7 @@ describe('getFeatureFlag', () => {
20212020
})
20222021
).toEqual(true)
20232022

2024-
await testing.waitForPromises()
2023+
await waitForPromises()
20252024

20262025
expect(capturedMessage).toMatchObject({
20272026
distinct_id: 'some-distinct-id',

0 commit comments

Comments
 (0)