feat: add script reporting more errors

This commit is contained in:
Oliver Eyton-Williams
2020-08-27 15:31:01 +02:00
committed by Mrugesh Mohapatra
parent e9bd88d245
commit 189b9081ca
3 changed files with 69 additions and 12 deletions

View File

@ -55,13 +55,21 @@ const { createPoly } = require('../../utils/polyvinyl');
const testEvaluator = require('../../client/config/test-evaluator').filename;
// rethrow unhandled rejections to make sure the tests exit with -1
process.on('unhandledRejection', err => {
cleanup();
process.on('unhandledRejection', err => handleRejection(err));
const handleRejection = err => {
// setting the error code because node does not (yet) exit with a non-zero
// code on unhandled exceptions.
process.exitCode = 1;
throw err;
});
cleanup();
if (process.env.FULL_OUTPUT === 'true') {
// some errors *may* not be reported, since cleanup is triggered by the
// first error and that starts shutting down the browser and the server.
console.error(err);
} else {
throw err;
}
};
const dom = new jsdom.JSDOM('');
global.document = dom.window.document;
@ -97,13 +105,7 @@ let page;
setup()
.then(runTests)
.catch(err => {
cleanup();
// setting the error code because node does not (yet) exit with a non-zero
// code on unhandled exceptions.
process.exitCode = 1;
throw err;
});
.catch(err => handleRejection(err));
async function setup() {
if (process.env.npm_config_superblock && process.env.npm_config_block) {