mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
a061781da3
PR-URL: https://github.com/nodejs/node/pull/48990 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
33 lines
742 B
JavaScript
33 lines
742 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
|
|
const { createRequire } = require('module');
|
|
|
|
const u = fixtures.fileURL('fake.js');
|
|
|
|
const reqToo = createRequire(u);
|
|
assert.deepStrictEqual(reqToo('./experimental'), { ofLife: 42 });
|
|
|
|
assert.throws(() => {
|
|
createRequire('https://github.com/nodejs/node/pull/27405/');
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_VALUE'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
createRequire('../');
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_VALUE'
|
|
});
|
|
|
|
assert.throws(() => {
|
|
createRequire({});
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_VALUE',
|
|
message: 'The argument \'filename\' must be a file URL object, file URL ' +
|
|
'string, or absolute path string. Received {}'
|
|
});
|