Suppress Test Logs (#6256)

* Suppress Test Logs

This will reduce some of the noise in the tests logs.

* replace deprecated buffer

* remove deprecation warnings

* fix geopoint

* Fix GraphQL

* postgres warnings
This commit is contained in:
Diamond Lewis
2019-12-03 18:21:12 -06:00
committed by GitHub
parent 188f033330
commit 985933955f
15 changed files with 867 additions and 669 deletions

View File

@@ -18,6 +18,7 @@ branches:
cache: cache:
directories: directories:
- "$HOME/.npm" - "$HOME/.npm"
- ".eslintcache"
stage: test stage: test
env: env:
global: global:

View File

@@ -145,6 +145,7 @@ describe('AdapterLoader', () => {
}); });
it('should load S3Adapter from direct passing', done => { it('should load S3Adapter from direct passing', done => {
spyOn(console, 'warn').and.callFake(() => {});
const s3Adapter = new S3Adapter('key', 'secret', 'bucket'); const s3Adapter = new S3Adapter('key', 'secret', 'bucket');
expect(() => { expect(() => {
const adapter = loadAdapter(s3Adapter, FilesAdapter); const adapter = loadAdapter(s3Adapter, FilesAdapter);

View File

@@ -106,6 +106,7 @@ describe('commander additions', () => {
}); });
it('should not override config.json', done => { it('should not override config.json', done => {
spyOn(console, 'log').and.callFake(() => {});
commander.loadDefinitions(testDefinitions); commander.loadDefinitions(testDefinitions);
commander.parse( commander.parse(
[ [
@@ -160,6 +161,7 @@ describe('commander additions', () => {
}); });
it('should load config from apps', done => { it('should load config from apps', done => {
spyOn(console, 'log').and.callFake(() => {});
commander.loadDefinitions(testDefinitions); commander.loadDefinitions(testDefinitions);
commander.parse([ commander.parse([
'node', 'node',

View File

@@ -31,7 +31,6 @@ describe('Email Verification Token Expiration: ', () => {
// wait for 1 second - simulate user behavior to some extent // wait for 1 second - simulate user behavior to some extent
setTimeout(() => { setTimeout(() => {
expect(sendEmailOptions).not.toBeUndefined(); expect(sendEmailOptions).not.toBeUndefined();
console.log(sendEmailOptions.link);
request({ request({
url: sendEmailOptions.link, url: sendEmailOptions.link,

View File

@@ -13,7 +13,7 @@ function newServer(port, dn, provokeSearchError = false) {
server.search('o=example', function(req, res, next) { server.search('o=example', function(req, res, next) {
if (provokeSearchError) { if (provokeSearchError) {
res.end(ldapjs.LDAP_SIZE_LIMIT_EXCEEDED); res.end(ldapjs.LDAP_SIZE_LIMIT_EXCEEDED);
return next(new ldapjs.NoSuchObjectError('fake error')); return next();
} }
const obj = { const obj = {
dn: req.dn.toString(), dn: req.dn.toString(),

File diff suppressed because it is too large Load Diff

View File

@@ -2073,7 +2073,6 @@ describe('Parse.Object testing', () => {
// Fetch object from server // Fetch object from server
object = await object.fetch(); object = await object.fetch();
console.log(object.id, object.get('jsonData'));
equal(object.get('jsonData'), { c: 'd' }); equal(object.get('jsonData'), { c: 'd' });
done(); done();

View File

@@ -36,6 +36,7 @@ describe('Server Url Checks', () => {
}); });
it('mark bad server url', done => { it('mark bad server url', done => {
spyOn(console, 'warn').and.callFake(() => {});
Parse.serverURL = 'notavalidurl'; Parse.serverURL = 'notavalidurl';
ParseServer.verifyServerUrl(function(result) { ParseServer.verifyServerUrl(function(result) {
if (result) { if (result) {

View File

@@ -2,6 +2,7 @@ const PostgresStorageAdapter = require('../lib/Adapters/Storage/Postgres/Postgre
.default; .default;
const databaseURI = const databaseURI =
'postgres://localhost:5432/parse_server_postgres_adapter_test_database'; 'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
const Config = require('../lib/Config');
const getColumns = (client, className) => { const getColumns = (client, className) => {
return client.map( return client.map(
@@ -16,8 +17,10 @@ const dropTable = (client, className) => {
}; };
describe_only_db('postgres')('PostgresStorageAdapter', () => { describe_only_db('postgres')('PostgresStorageAdapter', () => {
const adapter = new PostgresStorageAdapter({ uri: databaseURI }); let adapter;
beforeEach(() => { beforeEach(() => {
const config = Config.get('test');
adapter = config.database.adapter;
return adapter.deleteAllClasses(); return adapter.deleteAllClasses();
}); });

View File

@@ -54,7 +54,6 @@ describe('test validate_receipt endpoint', () => {
if (typeof body != 'object') { if (typeof body != 'object') {
fail('Body is not an object'); fail('Body is not an object');
} else { } else {
console.log(body);
expect(body.__type).toEqual('File'); expect(body.__type).toEqual('File');
const url = body.url; const url = body.url;
const otherResponse = await request({ const otherResponse = await request({

View File

@@ -18,6 +18,7 @@ if (global._babelPolyfill) {
console.error('We should not use polyfilled tests'); console.error('We should not use polyfilled tests');
process.exit(1); process.exit(1);
} }
process.noDeprecation = true;
const cache = require('../lib/cache').default; const cache = require('../lib/cache').default;
const ParseServer = require('../lib/index').ParseServer; const ParseServer = require('../lib/index').ParseServer;
@@ -243,7 +244,10 @@ afterEach(function(done) {
}); });
}) })
.then(() => Parse.User.logOut()) .then(() => Parse.User.logOut())
.then(() => {}, () => {}) // swallow errors .then(
() => {},
() => {}
) // swallow errors
.then(() => { .then(() => {
// Connection close events are not immediate on node 10+... wait a bit // Connection close events are not immediate on node 10+... wait a bit
return new Promise(resolve => { return new Promise(resolve => {

View File

@@ -27,7 +27,7 @@ describe('server', () => {
}); });
it('show warning if any reserved characters in appId', done => { it('show warning if any reserved characters in appId', done => {
spyOn(console, 'warn').and.callThrough(); spyOn(console, 'warn').and.callFake(() => {});
reconfigureServer({ appId: 'test!-^' }).then(() => { reconfigureServer({ appId: 'test!-^' }).then(() => {
expect(console.warn).toHaveBeenCalled(); expect(console.warn).toHaveBeenCalled();
return done(); return done();
@@ -40,7 +40,7 @@ describe('server', () => {
url: 'http://localhost:8378/1/classes/TestObject', url: 'http://localhost:8378/1/classes/TestObject',
headers: { headers: {
Authorization: Authorization:
'Basic ' + new Buffer('test:' + 'test').toString('base64'), 'Basic ' + Buffer.from('test:' + 'test').toString('base64'),
}, },
}).then(response => { }).then(response => {
expect(response.status).toEqual(200); expect(response.status).toEqual(200);
@@ -56,7 +56,7 @@ describe('server', () => {
headers: { headers: {
Authorization: Authorization:
'Basic ' + 'Basic ' +
new Buffer('test:javascript-key=' + 'test').toString('base64'), Buffer.from('test:javascript-key=' + 'test').toString('base64'),
}, },
}).then(response => { }).then(response => {
expect(response.status).toEqual(200); expect(response.status).toEqual(200);

View File

@@ -77,8 +77,7 @@ function getAppleCertificate(publicKeyUrl) {
} }
function convertTimestampToBigEndian(timestamp) { function convertTimestampToBigEndian(timestamp) {
const buffer = new Buffer(8); const buffer = Buffer.alloc(8);
buffer.fill(0);
const high = ~~(timestamp / 0xffffffff); const high = ~~(timestamp / 0xffffffff);
const low = timestamp % (0xffffffff + 0x1); const low = timestamp % (0xffffffff + 0x1);

View File

@@ -13,6 +13,8 @@ export function createClient(uri, databaseOptions) {
} }
const initOptions = dbOptions.initOptions || {}; const initOptions = dbOptions.initOptions || {};
initOptions.noWarnings = process && process.env.TESTING;
const pgp = require('pg-promise')(initOptions); const pgp = require('pg-promise')(initOptions);
const client = pgp(dbOptions); const client = pgp(dbOptions);

View File

@@ -343,7 +343,9 @@ export function handleParseErrors(err, req, res, next) {
} else if (err.status && err.message) { } else if (err.status && err.message) {
res.status(err.status); res.status(err.status);
res.json({ error: err.message }); res.json({ error: err.message });
next(err); if (!(process && process.env.TESTING)) {
next(err);
}
} else { } else {
log.error('Uncaught internal server error.', err, err.stack); log.error('Uncaught internal server error.', err, err.stack);
res.status(500); res.status(500);
@@ -351,7 +353,9 @@ export function handleParseErrors(err, req, res, next) {
code: Parse.Error.INTERNAL_SERVER_ERROR, code: Parse.Error.INTERNAL_SERVER_ERROR,
message: 'Internal server error.', message: 'Internal server error.',
}); });
next(err); if (!(process && process.env.TESTING)) {
next(err);
}
} }
} }