summaryrefslogtreecommitdiff
path: root/test/es-module/test-esm-exports.mjs
diff options
context:
space:
mode:
authorRongjian Zhang <pd4d10@gmail.com>2019-11-24 12:40:40 +0800
committerGuy Bedford <guybedford@gmail.com>2019-12-04 22:36:37 -0500
commitaa4c57ae7e74a623f5255a7f05a6ff9d5bc335d0 (patch)
tree9d7ab21bd8ace8e731ae5ecf9c79489236fe0455 /test/es-module/test-esm-exports.mjs
parent110dc02747473ae8193d71c1aa9cbedd71bfaa01 (diff)
downloadandroid-node-v8-aa4c57ae7e74a623f5255a7f05a6ff9d5bc335d0.tar.gz
android-node-v8-aa4c57ae7e74a623f5255a7f05a6ff9d5bc335d0.tar.bz2
android-node-v8-aa4c57ae7e74a623f5255a7f05a6ff9d5bc335d0.zip
module: add warnings for experimental flags
PR-URL: https://github.com/nodejs/node/pull/30617 Fixes: https://github.com/nodejs/node/issues/30600 Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'test/es-module/test-esm-exports.mjs')
-rw-r--r--test/es-module/test-esm-exports.mjs32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs
index a361bafaa8..73a86793a2 100644
--- a/test/es-module/test-esm-exports.mjs
+++ b/test/es-module/test-esm-exports.mjs
@@ -1,6 +1,8 @@
// Flags: --experimental-modules
import { mustCall } from '../common/index.mjs';
+import { path } from '../common/fixtures.mjs';
import { ok, deepStrictEqual, strictEqual } from 'assert';
+import { spawn } from 'child_process';
import { requireFixture, importFixture } from '../fixtures/pkgexports.mjs';
import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js';
@@ -149,3 +151,33 @@ function assertIncludes(actual, expected) {
ok(actual.toString().indexOf(expected) !== -1,
`${JSON.stringify(actual)} includes ${JSON.stringify(expected)}`);
}
+
+// Test warning message
+[
+ [
+ '--experimental-conditional-exports',
+ '/es-modules/conditional-exports.js',
+ 'Conditional exports',
+ ],
+ [
+ '--experimental-resolve-self',
+ '/node_modules/pkgexports/resolve-self.js',
+ 'Package name self resolution',
+ ],
+].forEach(([flag, file, message]) => {
+ const child = spawn(process.execPath, [flag, path(file)]);
+
+ let stderr = '';
+ child.stderr.setEncoding('utf8');
+ child.stderr.on('data', (data) => {
+ stderr += data;
+ });
+ child.on('close', (code, signal) => {
+ strictEqual(code, 0);
+ strictEqual(signal, null);
+ ok(stderr.toString().includes(
+ `ExperimentalWarning: ${message} is an experimental feature. ` +
+ 'This feature could change at any time'
+ ));
+ });
+});