@@ -23,6 +23,7 @@ import './assertions'
23
23
import { EventType } from '../src/internal/model/Event'
24
24
import { ForbiddenException , TimeoutException } from '../src/BKTExceptions'
25
25
import { ApiId , MetricsEventType } from '../src/internal/model/MetricsEventData'
26
+ import { fetchLike } from './fetchProvider'
26
27
27
28
function getDefaultComponent ( client : BKTClient ) : DefaultComponent {
28
29
return ( client as BKTClientImpl ) . component as DefaultComponent
@@ -38,7 +39,7 @@ suite('e2e/events', () => {
38
39
apiKey : import . meta. env . VITE_BKT_API_KEY ,
39
40
featureTag : 'javascript' ,
40
41
appVersion : '1.2.3' ,
41
- fetch : window . fetch ,
42
+ fetch : fetchLike ,
42
43
// DO NOT remove this line
43
44
// Because the tests are asynchronous and share the same local storage,
44
45
// It might fail randomly, having more or fewer events in the storage when checking the test.
@@ -55,7 +56,6 @@ suite('e2e/events', () => {
55
56
56
57
afterEach ( ( ) => {
57
58
destroyBKTClient ( )
58
- localStorage . clear ( )
59
59
} )
60
60
61
61
test ( 'goal event' , async ( ) => {
@@ -174,14 +174,14 @@ suite('e2e/events', () => {
174
174
175
175
test ( 'Using a random string in the api key setting should throw Forbidden' , async ( ) => {
176
176
destroyBKTClient ( )
177
- localStorage . clear ( )
177
+ if ( typeof localStorage !== 'undefined' ) { localStorage . clear ( ) }
178
178
179
179
config = defineBKTConfig ( {
180
180
apiEndpoint : import . meta. env . VITE_BKT_API_ENDPOINT ,
181
181
apiKey : 'some-random-string' ,
182
182
featureTag : 'javascript' ,
183
183
appVersion : '1.2.3' ,
184
- fetch : window . fetch ,
184
+ fetch : fetchLike ,
185
185
} )
186
186
187
187
user = defineBKTUser ( {
@@ -224,7 +224,7 @@ suite('e2e/events', () => {
224
224
apiKey : import . meta. env . VITE_BKT_API_KEY ,
225
225
featureTag : 'javascript' ,
226
226
appVersion : '1.2.3' ,
227
- fetch : window . fetch ,
227
+ fetch : fetchLike ,
228
228
} )
229
229
230
230
await initializeBKTClient ( config , user )
@@ -257,14 +257,14 @@ suite('e2e/events', () => {
257
257
258
258
test ( 'Using a random string in the featureTag setting should not affect api request' , async ( ) => {
259
259
destroyBKTClient ( )
260
- localStorage . clear ( )
260
+ if ( typeof localStorage !== 'undefined' ) { localStorage . clear ( ) }
261
261
262
262
config = defineBKTConfig ( {
263
263
apiEndpoint : import . meta. env . VITE_BKT_API_ENDPOINT ,
264
264
apiKey : import . meta. env . VITE_BKT_API_KEY ,
265
265
featureTag : 'some-random-feature-tag' ,
266
266
appVersion : '1.2.3' ,
267
- fetch : window . fetch ,
267
+ fetch : fetchLike ,
268
268
} )
269
269
270
270
user = defineBKTUser ( {
@@ -278,14 +278,14 @@ suite('e2e/events', () => {
278
278
// setting a very low value for the timeout
279
279
280
280
destroyBKTClient ( )
281
- localStorage . clear ( )
281
+ if ( typeof localStorage !== 'undefined' ) { localStorage . clear ( ) }
282
282
283
283
config = defineBKTConfig ( {
284
284
apiEndpoint : import . meta. env . VITE_BKT_API_ENDPOINT ,
285
285
apiKey : import . meta. env . VITE_BKT_API_KEY ,
286
286
featureTag : 'javascript' ,
287
287
appVersion : '1.2.3' ,
288
- fetch : window . fetch ,
288
+ fetch : fetchLike ,
289
289
} )
290
290
291
291
user = defineBKTUser ( {
0 commit comments