@@ -40,7 +40,7 @@ describe('Analytics service unit tests:', () => {
4040 const mod = await import ( '../services/analytics.service.js' ) ;
4141 AnalyticsService = mod . default ;
4242
43- AnalyticsService . init ( ) ;
43+ await AnalyticsService . init ( ) ;
4444 AnalyticsService . track ( 'user-1' , 'test-event' ) ;
4545 AnalyticsService . identify ( 'user-1' , { name : 'Alice' } ) ;
4646 AnalyticsService . groupIdentify ( 'company' , 'org-1' , { name : 'Acme' } ) ;
@@ -57,7 +57,7 @@ describe('Analytics service unit tests:', () => {
5757 const mod = await import ( '../services/analytics.service.js' ) ;
5858 AnalyticsService = mod . default ;
5959
60- AnalyticsService . init ( ) ;
60+ await AnalyticsService . init ( ) ;
6161 AnalyticsService . track ( 'user-1' , 'test-event' ) ;
6262
6363 const { PostHog } = await import ( 'posthog-node' ) ;
@@ -72,7 +72,7 @@ describe('Analytics service unit tests:', () => {
7272 const mod = await import ( '../services/analytics.service.js' ) ;
7373 AnalyticsService = mod . default ;
7474
75- AnalyticsService . init ( ) ;
75+ await AnalyticsService . init ( ) ;
7676
7777 const result = await AnalyticsService . getFeatureFlag ( 'my-flag' , 'user-1' ) ;
7878 expect ( result ) . toBeUndefined ( ) ;
@@ -86,7 +86,7 @@ describe('Analytics service unit tests:', () => {
8686 const mod = await import ( '../services/analytics.service.js' ) ;
8787 AnalyticsService = mod . default ;
8888
89- AnalyticsService . init ( ) ;
89+ await AnalyticsService . init ( ) ;
9090
9191 const result = await AnalyticsService . isFeatureEnabled ( 'my-flag' , 'user-1' ) ;
9292 expect ( result ) . toBeUndefined ( ) ;
@@ -100,7 +100,7 @@ describe('Analytics service unit tests:', () => {
100100 const mod = await import ( '../services/analytics.service.js' ) ;
101101 AnalyticsService = mod . default ;
102102
103- AnalyticsService . init ( ) ;
103+ await AnalyticsService . init ( ) ;
104104 await expect ( AnalyticsService . shutdown ( ) ) . resolves . toBeUndefined ( ) ;
105105 } ) ;
106106 } ) ;
@@ -121,7 +121,7 @@ describe('Analytics service unit tests:', () => {
121121 const mod = await import ( '../services/analytics.service.js' ) ;
122122 AnalyticsService = mod . default ;
123123
124- AnalyticsService . init ( ) ;
124+ await AnalyticsService . init ( ) ;
125125
126126 const { PostHog } = await import ( 'posthog-node' ) ;
127127 expect ( PostHog ) . toHaveBeenCalledWith ( 'phc_test_key' , { host : 'https://test.posthog.com' } ) ;
@@ -145,7 +145,7 @@ describe('Analytics service unit tests:', () => {
145145 const mod = await import ( '../services/analytics.service.js' ) ;
146146 AnalyticsService = mod . default ;
147147
148- AnalyticsService . init ( ) ;
148+ await AnalyticsService . init ( ) ;
149149
150150 const { PostHog } = await import ( 'posthog-node' ) ;
151151 expect ( PostHog ) . toHaveBeenCalledWith ( 'phc_test_key' , { host : 'https://us.i.posthog.com' } ) ;
@@ -155,7 +155,7 @@ describe('Analytics service unit tests:', () => {
155155 const mod = await import ( '../services/analytics.service.js' ) ;
156156 AnalyticsService = mod . default ;
157157
158- AnalyticsService . init ( ) ;
158+ await AnalyticsService . init ( ) ;
159159 AnalyticsService . track ( 'user-1' , 'page_view' , { path : '/' } , { company : 'org-1' } ) ;
160160
161161 expect ( mockPostHogInstance . capture ) . toHaveBeenCalledWith ( {
@@ -170,7 +170,7 @@ describe('Analytics service unit tests:', () => {
170170 const mod = await import ( '../services/analytics.service.js' ) ;
171171 AnalyticsService = mod . default ;
172172
173- AnalyticsService . init ( ) ;
173+ await AnalyticsService . init ( ) ;
174174 AnalyticsService . identify ( 'user-1' , { email : 'a@b.com' } ) ;
175175
176176 expect ( mockPostHogInstance . identify ) . toHaveBeenCalledWith ( {
@@ -183,7 +183,7 @@ describe('Analytics service unit tests:', () => {
183183 const mod = await import ( '../services/analytics.service.js' ) ;
184184 AnalyticsService = mod . default ;
185185
186- AnalyticsService . init ( ) ;
186+ await AnalyticsService . init ( ) ;
187187 AnalyticsService . groupIdentify ( 'company' , 'org-1' , { name : 'Acme' } ) ;
188188
189189 expect ( mockPostHogInstance . groupIdentify ) . toHaveBeenCalledWith ( {
@@ -197,7 +197,7 @@ describe('Analytics service unit tests:', () => {
197197 const mod = await import ( '../services/analytics.service.js' ) ;
198198 AnalyticsService = mod . default ;
199199
200- AnalyticsService . init ( ) ;
200+ await AnalyticsService . init ( ) ;
201201 const result = await AnalyticsService . getFeatureFlag ( 'my-flag' , 'user-1' , { groups : { } } ) ;
202202
203203 expect ( mockPostHogInstance . getFeatureFlag ) . toHaveBeenCalledWith ( 'my-flag' , 'user-1' , { groups : { } } ) ;
@@ -208,7 +208,7 @@ describe('Analytics service unit tests:', () => {
208208 const mod = await import ( '../services/analytics.service.js' ) ;
209209 AnalyticsService = mod . default ;
210210
211- AnalyticsService . init ( ) ;
211+ await AnalyticsService . init ( ) ;
212212 const result = await AnalyticsService . isFeatureEnabled ( 'my-flag' , 'user-1' , { groups : { } } ) ;
213213
214214 expect ( mockPostHogInstance . isFeatureEnabled ) . toHaveBeenCalledWith ( 'my-flag' , 'user-1' , { groups : { } } ) ;
@@ -219,7 +219,7 @@ describe('Analytics service unit tests:', () => {
219219 const mod = await import ( '../services/analytics.service.js' ) ;
220220 AnalyticsService = mod . default ;
221221
222- AnalyticsService . init ( ) ;
222+ await AnalyticsService . init ( ) ;
223223 await AnalyticsService . shutdown ( ) ;
224224
225225 expect ( mockPostHogInstance . shutdown ) . toHaveBeenCalled ( ) ;
@@ -229,7 +229,7 @@ describe('Analytics service unit tests:', () => {
229229 const mod = await import ( '../services/analytics.service.js' ) ;
230230 AnalyticsService = mod . default ;
231231
232- AnalyticsService . init ( ) ;
232+ await AnalyticsService . init ( ) ;
233233 await AnalyticsService . shutdown ( ) ;
234234
235235 // After shutdown, track should be a no-op (no error thrown)
0 commit comments