1const { Module: { createRequire } } = require('module'); 2const createdRequire = createRequire(__filename); 3 4// Although, require('../common') works locally, that couldn't be used here 5// because we set NODE_TEST_DIR=/Users/iojs/node-tmp on Jenkins CI. 6const { expectWarning } = createdRequire(process.env.COMMON_DIRECTORY); 7 8expectWarning('ExperimentalWarning', 9 'Single executable application is an experimental feature and ' + 10 'might change at any time'); 11 12// Should be possible to require core modules that optionally require the 13// "node:" scheme. 14const { deepStrictEqual, strictEqual, throws } = require('assert'); 15const { dirname } = require('node:path'); 16 17// Should be possible to require a core module that requires using the "node:" 18// scheme. 19{ 20 const { test } = require('node:test'); 21 strictEqual(typeof test, 'function'); 22} 23 24// Should not be possible to require a core module without the "node:" scheme if 25// it requires using the "node:" scheme. 26throws(() => require('test'), { 27 code: 'ERR_UNKNOWN_BUILTIN_MODULE', 28}); 29 30deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']); 31 32strictEqual(require.cache, undefined); 33strictEqual(require.extensions, undefined); 34strictEqual(require.main, module); 35strictEqual(require.resolve, undefined); 36 37strictEqual(__filename, process.execPath); 38strictEqual(__dirname, dirname(process.execPath)); 39strictEqual(module.exports, exports); 40 41throws(() => require('./requirable.js'), { 42 code: 'ERR_UNKNOWN_BUILTIN_MODULE', 43}); 44 45const requirable = createdRequire('./requirable.js'); 46deepStrictEqual(requirable, { 47 hello: 'world', 48}); 49 50console.log('Hello, world! '); 51