node/test/parallel/test-console-assign-undefined.js
Ruben Bridgewater f85d5996db
test: improve common.expectsError
The output is now improved by showing most properties all at once.
Besides that this adds a warning to use `assert.throws` instead
due to a better output.

PR-URL: https://github.com/nodejs/node/pull/19797
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-04-23 15:33:50 +02:00

29 lines
605 B
JavaScript

'use strict';
// Patch global.console before importing modules that may modify the console
// object.
const tmp = global.console;
global.console = 42;
require('../common');
const assert = require('assert');
// Originally the console had a getter. Test twice to verify it had no side
// effect.
assert.strictEqual(global.console, 42);
assert.strictEqual(global.console, 42);
assert.throws(
() => console.log('foo'),
{ name: 'TypeError' }
);
global.console = 1;
assert.strictEqual(global.console, 1);
assert.strictEqual(console, 1);
// Reset the console
global.console = tmp;
console.log('foo');