Skip to content

Commit

Permalink
test: improve assert messages in repl-reset-event
Browse files Browse the repository at this point in the history
PR-URL: #16836
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
AdriVanHoudt authored and gibfahn committed Dec 20, 2017
1 parent bd4b97f commit a50366f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/parallel/test-repl-reset-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ common.globalCheck = false;

const assert = require('assert');
const repl = require('repl');
const util = require('util');

// Create a dummy stream that does nothing
const dummy = new common.ArrayStream();
Expand All @@ -17,11 +18,13 @@ function testReset(cb) {
r.context.foo = 42;
r.on('reset', common.mustCall(function(context) {
assert(!!context, 'REPL did not emit a context with reset event');
assert.strictEqual(context, r.context, 'REPL emitted incorrect context');
assert.strictEqual(context, r.context, 'REPL emitted incorrect context. ' +
`context is ${util.inspect(context)}, expected ${util.inspect(r.context)}`);
assert.strictEqual(
context.foo,
undefined,
'REPL emitted the previous context, and is not using global as context'
'REPL emitted the previous context and is not using global as context. ' +
`context.foo is ${context.foo}, expected undefined.`
);
context.foo = 42;
cb();
Expand All @@ -40,7 +43,8 @@ function testResetGlobal() {
assert.strictEqual(
context.foo,
42,
'"foo" property is missing from REPL using global as context'
'"foo" property is different from REPL using global as context. ' +
`context.foo is ${context.foo}, expected 42.`
);
}));
r.resetContext();
Expand Down

0 comments on commit a50366f

Please sign in to comment.