mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 10:54:13 +00:00

The `test/common` module has the capability to identify if any variable is leaked to the global scope and fail the test. So that has to be imported at the beginning. PR-URL: https://github.com/nodejs/node/pull/7786 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
|
// Flags: --expose_internals --no-warnings
|
|
|
|
// The --no-warnings flag only supresses writing the warning to stderr, not the
|
|
// emission of the corresponding event. This test file can be run without it.
|
|
|
|
const common = require('../common');
|
|
process.noDeprecation = true;
|
|
|
|
const assert = require('assert');
|
|
|
|
function listener() {
|
|
common.fail('received unexpected warning');
|
|
}
|
|
|
|
process.addListener('warning', listener);
|
|
|
|
const internalUtil = require('internal/util');
|
|
internalUtil.printDeprecationMessage('Something is deprecated.');
|
|
|
|
// The warning would be emitted in the next tick, so continue after that.
|
|
process.nextTick(common.mustCall(() => {
|
|
// Check that deprecations can be re-enabled.
|
|
process.noDeprecation = false;
|
|
process.removeListener('warning', listener);
|
|
|
|
process.addListener('warning', common.mustCall((warning) => {
|
|
assert.strictEqual(warning.name, 'DeprecationWarning');
|
|
assert.strictEqual(warning.message, 'Something else is deprecated.');
|
|
}));
|
|
|
|
internalUtil.printDeprecationMessage('Something else is deprecated.');
|
|
}));
|