Skip to content

Commit

Permalink
test: improve assertion messages
Browse files Browse the repository at this point in the history
Print content of domain stack if it doesn't match expected values
PR-URL: #16885
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
  • Loading branch information
Neil Vass authored and MylesBorins committed Nov 17, 2017
1 parent 7ba0375 commit 6c57399
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/parallel/test-domain-safe-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
// Make sure the domain stack doesn't get clobbered by un-matched .exit()

require('../common');
const assert = require('assert');
const domain = require('domain');
const util = require('util');

const a = domain.create();
const b = domain.create();

a.enter(); // push
b.enter(); // push
assert.deepStrictEqual(domain._stack, [a, b], 'b not pushed');
assert.deepStrictEqual(domain._stack, [a, b], 'Unexpected stack shape ' +
`(domain._stack = ${util.inspect(domain._stack)})`);

domain.create().exit(); // no-op
assert.deepStrictEqual(domain._stack, [a, b], 'stack mangled!');
assert.deepStrictEqual(domain._stack, [a, b], 'Unexpected stack shape ' +
`(domain._stack = ${util.inspect(domain._stack)})`);

0 comments on commit 6c57399

Please sign in to comment.