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:
directories:
- "$HOME/.npm"
- ".eslintcache"
stage: test
env:
global:

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,7 @@ function newServer(port, dn, provokeSearchError = false) {
server.search('o=example', function(req, res, next) {
if (provokeSearchError) {
res.end(ldapjs.LDAP_SIZE_LIMIT_EXCEEDED);
return next(new ldapjs.NoSuchObjectError('fake error'));
return next();
}
const obj = {
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
object = await object.fetch();
console.log(object.id, object.get('jsonData'));
equal(object.get('jsonData'), { c: 'd' });
done();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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