From 21ec917152c3fa015a2ad6d31362d671299e03ba Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Wed, 13 Dec 2017 22:40:31 +0530 Subject: [PATCH] test: coverage for emitExperimentalWarning PR-URL: https://github.com/nodejs/node/pull/17635 Reviewed-By: Anatoli Papirovski Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- .../test-util-emit-experimental-warning.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/parallel/test-util-emit-experimental-warning.js diff --git a/test/parallel/test-util-emit-experimental-warning.js b/test/parallel/test-util-emit-experimental-warning.js new file mode 100644 index 00000000000000..1c1759a428307e --- /dev/null +++ b/test/parallel/test-util-emit-experimental-warning.js @@ -0,0 +1,17 @@ +'use strict'; +// Flags: --expose-internals +const common = require('../common'); +const assert = require('assert'); +const { emitExperimentalWarning } = require('internal/util'); + +// This test ensures that the emitExperimentalWarning in internal/util emits a +// warning when passed an unsupported feature and that it simply returns +// when passed the same feature multiple times. + +process.on('warning', common.mustCall((warning) => { + assert(/is an experimental feature/.test(warning.message)); +}, 2)); + +emitExperimentalWarning('feature1'); +emitExperimentalWarning('feature1'); // should not warn +emitExperimentalWarning('feature2');