1
1
import { PostHog } from '@/entrypoints/index.node'
2
2
import { PostHogOptions } from '@/types'
3
- import { apiImplementation , apiImplementationV4 } from './utils'
4
- import { testing } from '@posthog/core'
3
+ import { apiImplementation , apiImplementationV4 , waitForPromises } from './utils'
5
4
import { PostHogV2FlagsResponse } from '@posthog/core'
6
5
7
6
jest . spyOn ( console , 'debug' ) . mockImplementation ( )
@@ -36,7 +35,7 @@ describe('flags v2', () => {
36
35
expect ( result ) . toBe ( undefined )
37
36
expect ( mockedFetch ) . toHaveBeenCalledWith ( 'http://example.com/flags/?v=2&config=true' , expect . any ( Object ) )
38
37
39
- await testing . waitForPromises ( )
38
+ await waitForPromises ( )
40
39
expect ( capturedMessage ) . toMatchObject ( {
41
40
distinct_id : 'some-distinct-id' ,
42
41
event : '$feature_flag_called' ,
@@ -150,7 +149,7 @@ describe('flags v2', () => {
150
149
expect ( result ) . toBe ( expectedResponse )
151
150
expect ( mockedFetch ) . toHaveBeenCalledWith ( 'http://example.com/flags/?v=2&config=true' , expect . any ( Object ) )
152
151
153
- await testing . waitForPromises ( )
152
+ await waitForPromises ( )
154
153
expect ( capturedMessage ) . toMatchObject ( {
155
154
distinct_id : 'some-distinct-id' ,
156
155
event : '$feature_flag_called' ,
@@ -213,7 +212,7 @@ describe('flags v2', () => {
213
212
expect ( result ) . toEqual ( [ 0 , 1 , 2 ] )
214
213
expect ( mockedFetch ) . toHaveBeenCalledWith ( 'http://example.com/flags/?v=2&config=true' , expect . any ( Object ) )
215
214
216
- await testing . waitForPromises ( )
215
+ await waitForPromises ( )
217
216
expect ( capturedMessage ) . toBeUndefined ( )
218
217
} )
219
218
} )
@@ -300,7 +299,7 @@ describe('flags v2', () => {
300
299
} )
301
300
302
301
await posthog . getFeatureFlag ( 'error-flag' , 'some-distinct-id' )
303
- await testing . waitForPromises ( )
302
+ await waitForPromises ( )
304
303
expect ( capturedMessage ) . toBeUndefined ( )
305
304
} )
306
305
} )
@@ -326,7 +325,7 @@ describe('flags v1', () => {
326
325
expect ( result ) . toBe ( undefined )
327
326
expect ( mockedFetch ) . toHaveBeenCalledWith ( 'http://example.com/flags/?v=2&config=true' , expect . any ( Object ) )
328
327
329
- await testing . waitForPromises ( )
328
+ await waitForPromises ( )
330
329
expect ( capturedMessage ) . toMatchObject ( {
331
330
distinct_id : 'some-distinct-id' ,
332
331
event : '$feature_flag_called' ,
@@ -372,7 +371,7 @@ describe('flags v1', () => {
372
371
expect ( result ) . toEqual ( [ 0 , 1 , 2 ] )
373
372
expect ( mockedFetch ) . toHaveBeenCalledWith ( 'http://example.com/flags/?v=2&config=true' , expect . any ( Object ) )
374
373
375
- await testing . waitForPromises ( )
374
+ await waitForPromises ( )
376
375
expect ( capturedMessage ) . toBeUndefined ( )
377
376
} )
378
377
} )
0 commit comments