Skip to content

Commit cc55f5b

Browse files
committed
Fix IE analytics better
1 parent 4845e53 commit cc55f5b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

config/karma.saucelabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ module.exports = function(config) {
201201
maxLogLines: 5,
202202
suppressErrorSummary: false,
203203
suppressFailed: false,
204-
suppressPassed: true,
204+
suppressPassed: false,
205205
suppressSkipped: true,
206206
showSpecTiming: true,
207207
failFast: false

packages/analytics/index.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ describe('FirebaseAnalytics instance tests', () => {
8888
currency: 'USD'
8989
});
9090
// Clear event stack of async FID call.
91-
// For IE: Need to wrap it in another function as FID fetch is wrapped in initializeGAId.
92-
await (() => fidDeferred.promise);
91+
// For IE: Need then() or else "expect" runs immediately on FID resolve
92+
// before the other statements in initializeGAId.
93+
await fidDeferred.promise.then();
9394
expect(gtagStub).to.have.been.calledWith('js');
9495
expect(gtagStub).to.have.been.calledWith(
9596
GtagCommand.CONFIG,
@@ -159,8 +160,9 @@ describe('FirebaseAnalytics instance tests', () => {
159160
currency: 'USD'
160161
});
161162
// Clear event stack of async FID call.
162-
// For IE: Need to wrap it in another function as FID fetch is wrapped in initializeGAId.
163-
await (() => fidDeferred.promise);
163+
// For IE: Need then() or else "expect" runs immediately on FID resolve
164+
// before the other statements in initializeGAId.
165+
await fidDeferred.promise.then();
164166
expect(gtagStub).to.have.been.calledWith('js');
165167
expect(gtagStub).to.have.been.calledWith(
166168
GtagCommand.CONFIG,
@@ -197,8 +199,12 @@ describe('FirebaseAnalytics instance tests', () => {
197199
delete window['dataLayer'];
198200
removeGtagScript();
199201
});
200-
it('Adds the script tag to the page', () => {
202+
it('Adds the script tag to the page', async () => {
203+
const { initializedIdPromisesMap } = getGlobalVars();
204+
await initializedIdPromisesMap[analyticsId];
201205
expect(findGtagScriptOnPage()).to.not.be.null;
206+
expect(typeof window['gtag']).to.equal('function');
207+
expect(Array.isArray(window['dataLayer'])).to.be.true;
202208
});
203209
});
204210
});

0 commit comments

Comments
 (0)