From 9c12bdcb5c23ba9a3b3c80a6bc8bb942efe1dcb1 Mon Sep 17 00:00:00 2001 From: macbre Date: Mon, 26 Oct 2020 20:09:49 +0100 Subject: [PATCH] Makes the script crash on unhandled rejections instead of silently ignoring them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/facebook/jest/issues/5311#issuecomment-362752169 ✗ Errored » Asynchronous Error in Integration tests in test/integration-test.js /home/macbre/github/phantomas/test/integration-test.js:19 throw err; ^ Error: Protocol error (Performance.getMetrics): Session closed. Most likely the page has been closed. at CDPSession.send (/home/macbre/github/phantomas/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:195:35) at Page.metrics (/home/macbre/github/phantomas/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:699:45) at /home/macbre/github/phantomas/lib/browser.js:266:37 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) --- test/integration-test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/integration-test.js b/test/integration-test.js index 1b4251f0a..d6a63f251 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -12,6 +12,13 @@ var vows = require('vows'), var WEBROOT = 'http://127.0.0.1:8888'; // see start-server.sh +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + // run the test var suite = vows.describe('Integration tests').addBatch({ 'test server': {