MCPcopy Index your code
hub / github.com/nodejs/node / testReset

Function testReset

test/parallel/test-repl-reset-event.js:30–47  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

28common.allowGlobals(42);
29
30function testReset(cb) {
31 const { replServer } = startNewREPLServer();
32 replServer.context.foo = 42;
33 replServer.on('reset', common.mustCall(function(context) {
34 assert(!!context, 'REPL did not emit a context with reset event');
35 assert.strictEqual(context, replServer.context, 'REPL emitted incorrect context. ' +
36 `context is ${util.inspect(context)}, expected ${util.inspect(replServer.context)}`);
37 assert.strictEqual(
38 context.foo,
39 undefined,
40 'REPL emitted the previous context and is not using global as context. ' +
41 `context.foo is ${context.foo}, expected undefined.`
42 );
43 context.foo = 42;
44 cb();
45 }));
46 replServer.resetContext();
47}
48
49function testResetGlobal() {
50 const { replServer } = startNewREPLServer({ useGlobal: true });

Callers 1

Calls 6

startNewREPLServerFunction · 0.85
inspectMethod · 0.80
resetContextMethod · 0.80
cbFunction · 0.70
assertFunction · 0.50
onMethod · 0.45

Tested by

no test coverage detected