From 71b37eaf555d7898a4b6f73ca94a09e967fc7450 Mon Sep 17 00:00:00 2001 From: Chin Huang Date: Fri, 2 Feb 2018 15:03:07 -0800 Subject: [PATCH] test: add useful info to error msg and refactor Add useful info about process.domain to error meesages in the uncaughtException event listener and the beforeExit event listener. Refactor code such as using template literals, and also make sure uncaughtException listner is detached after firing once to avoid endless loop in case of exception throw in the beforeExit event listner. PR-URL: https://github.com/nodejs/node/pull/18541 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- ...domain-stack-empty-in-process-uncaughtexception.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-domain-stack-empty-in-process-uncaughtexception.js b/test/parallel/test-domain-stack-empty-in-process-uncaughtexception.js index 79ded2dd9d1424..e9e8ab12d59d2c 100644 --- a/test/parallel/test-domain-stack-empty-in-process-uncaughtexception.js +++ b/test/parallel/test-domain-stack-empty-in-process-uncaughtexception.js @@ -6,15 +6,18 @@ const assert = require('assert'); const d = domain.create(); -process.on('uncaughtException', common.mustCall(function onUncaught() { +process.once('uncaughtException', common.mustCall(function onUncaught() { assert.strictEqual( process.domain, null, - 'domains stack should be empty in uncaughtException handler'); + 'Domains stack should be empty in uncaughtException handler ' + + `but the value of process.domain is ${JSON.stringify(process.domain)}`); })); process.on('beforeExit', common.mustCall(function onBeforeExit() { - assert.strictEqual(process.domain, null, - 'domains stack should be empty in beforeExit handler'); + assert.strictEqual( + process.domain, null, + 'Domains stack should be empty in beforeExit handler ' + + `but the value of process.domain is ${JSON.stringify(process.domain)}`); })); d.run(function() {