File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
packages/analytics/testing/integration-tests Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,23 @@ async function checkForEventCalls(retryCount = 0): Promise<PerformanceEntry[]> {
50
50
if ( callsWithEvent . length === 0 ) {
51
51
return checkForEventCalls ( retryCount + 1 ) ;
52
52
} else {
53
+ console . log ( "Events: " , JSON . stringify ( callsWithEvent ) ) ;
53
54
return callsWithEvent ;
54
55
}
55
56
}
56
57
57
58
describe ( 'FirebaseAnalytics Integration Smoke Tests' , ( ) => {
58
59
let app : FirebaseApp ;
60
+
61
+ // Clear cookies to prevent persistence issues across tests when run in non-headless browsers.
62
+ // This is required since gtag/logEvent behaviour is dependent on the session state; if an event has already been logged
63
+ // in a session, the event will be sent in the request payload instead of the query string.
64
+ beforeEach ( ( ) => {
65
+ document . cookie . split ( ";" ) . forEach ( ( cookie ) => {
66
+ document . cookie = cookie . replace ( / ^ + / , "" ) . replace ( / = .* / , "=;expires=" + new Date ( ) . toUTCString ( ) + ";path=/" )
67
+ } ) ;
68
+ } )
69
+
59
70
describe ( 'Using getAnalytics()' , ( ) => {
60
71
afterEach ( ( ) => deleteApp ( app ) ) ;
61
72
it ( 'logEvent() sends correct network request.' , async ( ) => {
You can’t perform that action at this time.
0 commit comments