-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58a7b00
commit 85e9542
Showing
6 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import '../common/index.mjs'; | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
describe('import.meta.require', () => { | ||
it('should require a built-in module', () => { | ||
const requiredAssert = import.meta.require('node:assert'); | ||
assert.deepStrictEqual(assert, requiredAssert); | ||
}); | ||
|
||
it('should require a esm module', () => { | ||
const { foo, bar } = import.meta.require('../fixtures/es-module-loaders/module-named-exports.mjs'); | ||
assert.strictEqual(foo, 'foo'); | ||
assert.strictEqual(bar, 'bar'); | ||
}); | ||
|
||
it('should require a cjs module', () => { | ||
const { foo, bar } = import.meta.require('../fixtures/es-modules/cjs-module-exports.js'); | ||
assert.strictEqual(foo, 'foo'); | ||
assert.strictEqual(bar, 'bar'); | ||
}); | ||
|
||
it('should require a json module', () => { | ||
const { foo, bar } = import.meta.require('../fixtures/es-modules/foobar.json'); | ||
assert.strictEqual(foo, 'foo'); | ||
assert.strictEqual(bar, 'bar'); | ||
}); | ||
|
||
it('should throw MODULE_NOT_FOUND', () => { | ||
try { | ||
import.meta.require('does-not-exist'); | ||
assert.fail(); | ||
} catch (e) { | ||
assert.strictEqual(e.code, 'MODULE_NOT_FOUND'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
foo: 'foo', | ||
bar: 'bar' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"foo": "foo", | ||
"bar": "bar" | ||
} |