Skip to content

Commit

Permalink
test(e2e): de-flake some e2e tests with sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed May 15, 2021
1 parent 09ebe84 commit 32e16bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions packages/database/e2e/query/once.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ describe('database().ref().once()', function () {
}
});

// TODO flaky android
it('it calls when a child is added', async function () {
const value = Date.now();
const callback = sinon.spy();
const ref = firebase.database().ref(`${TEST_PATH}/childAdded`);

ref.once('child_added').then($ => callback($.val()));
await ref.child('foo').set(value);
await Utils.sleep(1000);
await Utils.sleep(2000);

callback.should.be.calledOnce();
callback.should.be.calledWith(value);
Expand All @@ -135,9 +136,9 @@ describe('database().ref().once()', function () {

await ref.child('foo').set(1);
ref.once('child_changed').then($ => callback($.val()));
await Utils.sleep(1000);
await Utils.sleep(2000);
await ref.child('foo').set(2);
await Utils.sleep(1000);
await Utils.sleep(2000);
callback.should.be.calledOnce();
callback.should.be.calledWith(2);
});
Expand All @@ -149,9 +150,9 @@ describe('database().ref().once()', function () {
await child.set('foo');

ref.once('child_removed').then($ => callback($.val()));
await Utils.sleep(1000);
await Utils.sleep(2000);
await child.remove();
await Utils.sleep(1000);
await Utils.sleep(2000);

callback.should.be.calledOnce();
callback.should.be.calledWith('foo');
Expand Down
4 changes: 2 additions & 2 deletions packages/database/e2e/reference/push.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('database().ref().push()', function () {
ref.push(value, () => {
callback();
});
await Utils.sleep(1000);
await Utils.sleep(2000);
callback.should.be.calledOnce();
});

Expand All @@ -86,7 +86,7 @@ describe('database().ref().push()', function () {
error.message.should.containEql("doesn't have permission to access");
callback();
});
await Utils.sleep(1000);
await Utils.sleep(2000);
callback.should.be.calledOnce();
});
});
2 changes: 1 addition & 1 deletion packages/firestore/e2e/QuerySnapshot.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('firestore.QuerySnapshot', function () {
.collection(`${COLLECTION}/${Utils.randString(12, '#aA')}/metadatachanges-true-false`);
const unsub = colRef.onSnapshot({ includeMetadataChanges: true }, callback);
await colRef.add({ foo: 'bar' });
await Utils.spyToBeCalledTimesAsync(callback, 3);
await Utils.spyToBeCalledTimesAsync(callback, 3, 10000);
unsub();

const snap1 = callback.args[0][0];
Expand Down

0 comments on commit 32e16bd

Please sign in to comment.