test: improve assert messages in repl-reset-event
PR-URL: https://github.com/nodejs/node/pull/16836 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
86527bd762
commit
bbcbcb810b
@ -25,6 +25,7 @@ common.globalCheck = false;
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
// Create a dummy stream that does nothing
|
// Create a dummy stream that does nothing
|
||||||
const dummy = new common.ArrayStream();
|
const dummy = new common.ArrayStream();
|
||||||
@ -38,11 +39,13 @@ function testReset(cb) {
|
|||||||
r.context.foo = 42;
|
r.context.foo = 42;
|
||||||
r.on('reset', common.mustCall(function(context) {
|
r.on('reset', common.mustCall(function(context) {
|
||||||
assert(!!context, 'REPL did not emit a context with reset event');
|
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(
|
assert.strictEqual(
|
||||||
context.foo,
|
context.foo,
|
||||||
undefined,
|
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;
|
context.foo = 42;
|
||||||
cb();
|
cb();
|
||||||
@ -61,7 +64,8 @@ function testResetGlobal() {
|
|||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
context.foo,
|
context.foo,
|
||||||
42,
|
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();
|
r.resetContext();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user