Skip to content

Commit e51cdbf

Browse files
committed
fix some failing tests
1 parent 72ebd44 commit e51cdbf

File tree

8 files changed

+46
-23
lines changed

8 files changed

+46
-23
lines changed

config/karma.saucelabs.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ if (!testConfigFile) {
3131
*/
3232
const browserMap = {
3333
// Desktop
34-
// Chrome_Windows: seleniumLauncher('chrome', 'Windows 10', 'latest'),
34+
Chrome_Windows: seleniumLauncher('chrome', 'Windows 10', 'latest')
3535
// Firefox_Windows: seleniumLauncher('firefox', 'Windows 10', 'latest'),
3636
// Safari_macOS: seleniumLauncher('safari', 'macOS 10.13', 'latest'),
3737
// Edge_Windows: seleniumLauncher('MicrosoftEdge', 'Windows 10', 'latest'),
38-
IE_Windows: seleniumLauncher('internet explorer', 'Windows 10', 'latest')
38+
// IE_Windows: seleniumLauncher('internet explorer', 'Windows 10', 'latest')
3939

4040
// Mobile
4141
// Safari_iOS: appiumLauncher('Safari', 'iPhone Simulator', 'iOS', '11.2'),
@@ -49,6 +49,14 @@ const packageConfigs = {
4949
messaging: {
5050
// Messaging currently only supports these browsers.
5151
browsers: ['Chrome_Windows', 'Firefox_Windows', 'Edge_Windows']
52+
},
53+
firestore: {
54+
browsers: [
55+
'Chrome_Windows',
56+
'Firefox_Windows',
57+
'Edge_Windows',
58+
'Safari_macOS'
59+
]
5260
}
5361
};
5462

@@ -170,7 +178,8 @@ module.exports = function(config) {
170178
'packages/polyfill/index.ts': ['webpack', 'sourcemap'],
171179
'**/test/**/*.ts': ['webpack', 'sourcemap'],
172180
'**/*.test.ts': ['webpack', 'sourcemap'],
173-
'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
181+
// Restore when ready to run Firestore unit tests in IE.
182+
// 'packages/firestore/test/**/bootstrap.ts': ['webpack', 'babel'],
174183
'integration/**/namespace.*': ['webpack', 'babel', 'sourcemap']
175184
},
176185

config/webpack.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
},
5555
{
5656
test: /\.js$/,
57-
include: [/node_modules\/chai-as-promised/, /webchannel-wrapper/],
57+
include: [/node_modules\/chai-as-promised/],
5858
use: {
5959
loader: 'babel-loader',
6060
options: {

integration/firestore/karma.conf.js

Lines changed: 1 addition & 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.

packages/firestore/karma.conf.js

Lines changed: 1 addition & 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,8 +15,6 @@
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
const { argv } = require('yargs');
2220

@@ -42,7 +40,6 @@ module.exports = function(config) {
4240
* --unit and --integration command-line arguments.
4341
*/
4442
function getTestFiles(argv) {
45-
console.log(argv);
4643
const unitTests = 'test/unit/bootstrap.ts';
4744
const integrationTests = 'test/integration/bootstrap.ts';
4845
if (argv.unit) {

packages/firestore/src/util/async_queue.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export class AsyncQueue {
360360
.catch((error: FirestoreError) => {
361361
this.failure = error;
362362
this.operationInProgress = false;
363-
const message = error.stack || error.message || '';
363+
const message = getMessageOrStack(error);
364364
logError('INTERNAL UNHANDLED ERROR: ', message);
365365

366366
// Re-throw the error so that this.tail becomes a rejected Promise and
@@ -413,10 +413,7 @@ export class AsyncQueue {
413413

414414
private verifyNotFailed(): void {
415415
if (this.failure) {
416-
fail(
417-
'AsyncQueue is already failed: ' +
418-
(this.failure.stack || this.failure.message)
419-
);
416+
fail('AsyncQueue is already failed: ' + getMessageOrStack(this.failure));
420417
}
421418
}
422419

@@ -518,3 +515,20 @@ export function wrapInUserErrorIfRecoverable(
518515
throw e;
519516
}
520517
}
518+
519+
/**
520+
* Chrome includes Error.message in Error.stack. Other browsers do not.
521+
* This returns expected output of message + stack when available.
522+
* @param error Error or FirestoreError
523+
*/
524+
function getMessageOrStack(error: Error): string {
525+
let message = error.message || '';
526+
if (error.stack) {
527+
if (error.stack.includes(error.message)) {
528+
message = error.stack;
529+
} else {
530+
message = error.message + '\n' + error.stack;
531+
}
532+
}
533+
return message;
534+
}

packages/firestore/test/unit/core/event_manager.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ describe('QueryListener', () => {
224224
const query = Query.atPath(path('rooms/Eros'));
225225

226226
const listener = queryListener(query, [], events);
227+
const error = new Error('bad');
227228

228-
listener.onError(Error('bad'));
229-
expect(events[0]).to.deep.equal(new Error('bad'));
229+
listener.onError(error);
230+
expect(events[0]).to.deep.equal(error);
230231
});
231232

232233
it('raises event for empty collection after sync', () => {

packages/firestore/test/unit/util/async_queue.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ describe('AsyncQueue', () => {
143143
const doStep = (n: number): Promise<number> =>
144144
defer(() => completedSteps.push(n));
145145
queue.enqueueAndForget(() => doStep(1));
146-
const last = queue.enqueueAfterDelay(timerId1, 5, () => doStep(4));
146+
// Flaky on Safari, increasing delay to 1000ms to try to increase reliability.
147+
const last = queue.enqueueAfterDelay(timerId1, 1000, () => doStep(4));
147148
// eslint-disable-next-line @typescript-eslint/no-floating-promises
148149
queue.enqueueAfterDelay(timerId2, 1, () => doStep(3));
149150
queue.enqueueAndForget(() => doStep(2));

scripts/run_saucelabs.js

Lines changed: 7 additions & 6 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.
@@ -36,10 +36,9 @@ const { configFiles } = yargs
3636
// runNextTest() pulls filenames one-by-one from this queue.
3737
const testFiles = configFiles.length
3838
? configFiles
39-
: glob
40-
.sync(`{packages,integration}/*/karma.conf.js`)
41-
// Automated tests in integration/firestore are currently disabled.
42-
// .filter(name => !name.includes('integration/firestore'));
39+
: glob.sync(`{packages,integration}/*/karma.conf.js`);
40+
// Automated tests in integration/firestore are currently disabled.
41+
// .filter(name => !name.includes('integration/firestore'));
4342

4443
// Get CI build number or generate one if running locally.
4544
const buildNumber =
@@ -68,7 +67,9 @@ async function runTest(testFile) {
6867
}
6968
if (testFile.includes('integration/firestore')) {
7069
console.log('Generating memory build.');
71-
await spawn('yarn', ['--cwd', 'integration/firestore', 'build:memory'], { stdio: 'inherit' });
70+
await spawn('yarn', ['--cwd', 'integration/firestore', 'build:memory'], {
71+
stdio: 'inherit'
72+
});
7273
console.log('Running tests on memory build.');
7374
const exitCode1 = await runKarma(testFile);
7475
// console.log('Generating persistence build.');

0 commit comments

Comments
 (0)