fix(tests): Stabilize flaky tests (#3876)

* Longer TTL, shorter wait

* Makes sure we wait for the logout

- Parse.User.logOut is async and was making a test flaky
This commit is contained in:
Florent Vilmart
2017-05-28 20:01:33 -04:00
committed by GitHub
parent 57efd89b3d
commit 73aafa2d24
2 changed files with 15 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ const InMemoryCache = require('../src/Adapters/Cache/InMemoryCache').default;
describe('InMemoryCache', function() { describe('InMemoryCache', function() {
var BASE_TTL = { var BASE_TTL = {
ttl: 10 ttl: 100
}; };
var NO_EXPIRE_TTL = { var NO_EXPIRE_TTL = {
ttl: NaN ttl: NaN
@@ -28,7 +28,7 @@ describe('InMemoryCache', function() {
var value = cache.get(KEY); var value = cache.get(KEY);
expect(value).toEqual(VALUE); expect(value).toEqual(VALUE);
wait(BASE_TTL.ttl * 5).then(() => { wait(BASE_TTL.ttl * 2).then(() => {
value = cache.get(KEY) value = cache.get(KEY)
expect(value).toEqual(null); expect(value).toEqual(null);
done(); done();

View File

@@ -1271,20 +1271,20 @@ describe('Parse.User testing', () => {
Parse.User._registerAuthenticationProvider(provider); Parse.User._registerAuthenticationProvider(provider);
Parse.User._logInWith("facebook", { Parse.User._logInWith("facebook", {
success: function() { success: function() {
Parse.User.logOut(); Parse.User.logOut().then(() => {
Parse.Cloud.beforeSave(Parse.User, function(req, res) {
res.error("Before save shouldn't be called on login");
});
Parse.Cloud.beforeSave(Parse.User, function(req, res) { Parse.User._logInWith("facebook", {
res.error("Before save shouldn't be called on login"); success: function() {
}); done();
},
Parse.User._logInWith("facebook", { error: function(model, error) {
success: function() { ok(undefined, error);
done(); done();
}, }
error: function(model, error) { });
ok(undefined, error);
done();
}
}); });
} }
}); });