forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong error thrown if loader is used (mochajs#4807)
- Loading branch information
1 parent
fe0ae17
commit 79622b8
Showing
6 changed files
with
65 additions
and
4 deletions.
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
18 changes: 18 additions & 0 deletions
18
test/integration/fixtures/esm/loader-with-module-not-found/loader-that-recognizes-ts.mjs
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,18 @@ | ||
import path from 'path' | ||
import {fileURLToPath} from 'url' | ||
|
||
/** | ||
* @param {string} specifier | ||
* @param {{ | ||
* conditions: !Array<string>, | ||
* parentURL: !(string | undefined), | ||
* }} context | ||
* @param {Function} defaultResolve | ||
* @returns {Promise<{ url: string }>} | ||
*/ | ||
export async function resolve(specifier, context, defaultResolve) { | ||
const extension = path.extname( | ||
fileURLToPath(/**@type {import('url').URL}*/ (new URL(specifier, context.parentURL))), | ||
) | ||
return await defaultResolve(specifier.replace('.ts', '.mjs'), context, defaultResolve) | ||
} |
1 change: 1 addition & 0 deletions
1
...xtures/esm/loader-with-module-not-found/test-that-imports-non-existing-module.fixture.mjs
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 @@ | ||
import 'non-existent-package'; |
2 changes: 2 additions & 0 deletions
2
...ixtures/esm/loader-with-module-not-found/test-that-imports-non-existing-module.fixture.ts
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,2 @@ | ||
// This file will be resolved to `test-that-imports-non-existing-module.fixture.mjs` by the loader | ||
import 'non-existent-package'; |
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