Skip to content

Commit 7b17e03

Browse files
authored
Fix Saucelabs tests in analytics and functions (#2845)
1 parent e062933 commit 7b17e03

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

.github/workflows/cross-browser-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
cross-browser-test:
1010
name: Cross-Browser (Saucelabs) Tests
1111
runs-on: ubuntu-latest
12-
if: github.event.pull_request.merged
1312
env:
1413
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
1514
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}

config/karma.saucelabs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -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: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google Inc.
3+
* Copyright 2019 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -88,7 +88,9 @@ describe('FirebaseAnalytics instance tests', () => {
8888
currency: 'USD'
8989
});
9090
// Clear event stack of async FID call.
91-
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();
9294
expect(gtagStub).to.have.been.calledWith('js');
9395
expect(gtagStub).to.have.been.calledWith(
9496
GtagCommand.CONFIG,
@@ -158,7 +160,9 @@ describe('FirebaseAnalytics instance tests', () => {
158160
currency: 'USD'
159161
});
160162
// Clear event stack of async FID call.
161-
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();
162166
expect(gtagStub).to.have.been.calledWith('js');
163167
expect(gtagStub).to.have.been.calledWith(
164168
GtagCommand.CONFIG,
@@ -195,8 +199,12 @@ describe('FirebaseAnalytics instance tests', () => {
195199
delete window['dataLayer'];
196200
removeGtagScript();
197201
});
198-
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];
199205
expect(findGtagScriptOnPage()).to.not.be.null;
206+
expect(typeof window['gtag']).to.equal('function');
207+
expect(Array.isArray(window['dataLayer'])).to.be.true;
200208
});
201209
});
202210
});

packages/functions/karma.conf.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -15,16 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
const karma = require('karma');
19-
const path = require('path');
2018
const karmaBase = require('../../config/karma.base');
2119

2220
const files = [`test/**/*`];
2321

2422
module.exports = function(config) {
2523
const karmaConfig = Object.assign({}, karmaBase, {
2624
// files to load into karma
27-
files: files,
25+
files,
2826
// frameworks to use
2927
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
3028
frameworks: ['mocha']

packages/functions/test/browser/callable.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google Inc.
3+
* Copyright 2017 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -43,6 +43,10 @@ describe('Firebase Functions > Call', () => {
4343
// TODO(klimt): Move this to the cross-platform tests and delete this file,
4444
// once instance id works there.
4545
it('instance id', async () => {
46+
if (!('Notification' in self)) {
47+
console.log('No Notification API: skipping instance id test.');
48+
return;
49+
}
4650
// mock firebase messaging
4751
const messagingMock: FirebaseMessaging = ({
4852
getToken: async () => 'iid'

0 commit comments

Comments
 (0)