mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:42:31 -05:00
test_runner: fix mocking modules with quote in their URL
PR-URL: https://github.com/nodejs/node/pull/55083 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
1 parent
fdae57f1e1
commit
7eaeba499a
3 files changed
+11
-1
No files matched your search
@@ -413,6 +413,15 @@ test('modules cannot be mocked multiple times at once', async (t) => {
|
||||
t.mock.module(fixture, { namedExports: { fn() { return 42; } } });
|
||||
await assert.rejects(import(fixture), { code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME' });
|
||||
});
|
||||
|
||||
await t.test('Importing a module with a quote in its URL should work', async (t) => {
|
||||
const fixture = fixtures.fileURL('module-mocking', 'don\'t-open.mjs');
|
||||
t.mock.module(fixture, { namedExports: { fn() { return 42; } } });
|
||||
|
||||
const mocked = await import(fixture);
|
||||
|
||||
assert.strictEqual(mocked.fn(), 42);
|
||||
});
|
||||
});
|
||||
|
||||
test('mocks are automatically restored', async (t) => {
|
||||
|
||||
Reference in new issue
Block a user