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 28, 2017
1 parent fce7902 commit 2043ce3
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
@@ -1,16 +1,19 @@
'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 2043ce3

Please sign in to comment.