node/test/parallel/test-repl-context.js
Michaël Zasso 9de2e159c4 test: add second argument to assert.throws
This adds RegExp or error constructor arguments to the remaining places
where it is missing in preparation for the commit that will enforce the
presence of at least two arguments.

PR-URL: https://github.com/nodejs/node/pull/12270
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-04-13 11:31:39 +02:00

27 lines
753 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');
// Create a dummy stream that does nothing
const stream = new common.ArrayStream();
// Test when useGlobal is false
testContext(repl.start({
input: stream,
output: stream,
useGlobal: false
}));
function testContext(repl) {
const context = repl.createContext();
// ensure that the repl context gets its own "console" instance
assert(context.console instanceof require('console').Console);
// ensure that the repl's global property is the context
assert.strictEqual(context.global, context);
// ensure that the repl console instance does not have a setter
assert.throws(() => context.console = 'foo', TypeError);
}