Skip to content

Commit

Permalink
Fix flaky tests (parse-community#2324)
Browse files Browse the repository at this point in the history
* Fix flaky test (There were open connections to the server left after the test finished)

* fix test that's happening on the end of the minute

* remove focus testing
  • Loading branch information
flovilmart authored and Rafael Santos committed Mar 16, 2017
1 parent d1be569 commit ee51538
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
3 changes: 2 additions & 1 deletion spec/RestCreate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ describe('rest create', () => {
expect(actual.getFullYear()).toEqual(expected.getFullYear());
expect(actual.getMonth()).toEqual(expected.getMonth());
expect(actual.getDate()).toEqual(expected.getDate());
expect(actual.getMinutes()).toEqual(expected.getMinutes());
// less than a minute, if test happen at the wrong time :/
expect(actual.getMinutes() - expected.getMinutes() <= 1).toBe(true);

done();
});
Expand Down
33 changes: 17 additions & 16 deletions spec/RestQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var rest = require('../src/rest');

var querystring = require('querystring');
var request = require('request');
var rp = require('request-promise');

var config = new Config('test');
let database = config.database;
Expand Down Expand Up @@ -167,37 +168,37 @@ describe('rest query', () => {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
};
request.get({

let p0 = rp.get({
headers: headers,
url: 'http://localhost:8378/1/classes/TestParameterEncode?'
+ querystring.stringify({
where: '{"foo":{"$ne": "baz"}}',
limit: 1
}).replace('=', '%3D'),
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
}).then(fail, (response) => {
let error = response.error;
var b = JSON.parse(error);
expect(b.code).toEqual(Parse.Error.INVALID_QUERY);
done();
});
}).then(() => {
var headers = {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
};
request.get({

let p1 = rp.get({
headers: headers,
url: 'http://localhost:8378/1/classes/TestParameterEncode?'
+ querystring.stringify({
limit: 1
}).replace('=', '%3D'),
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
}).then(fail, (response) => {
let error = response.error;
var b = JSON.parse(error);
expect(b.code).toEqual(Parse.Error.INVALID_QUERY);
done();
});
});
return Promise.all([p0, p1]);
}).then(done).catch((err) => {
console.error(err);
fail('should not fail');
done();
})
});

it('query with limit = 0', (done) => {
Expand Down

0 comments on commit ee51538

Please sign in to comment.