-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a new error type that is returned from the JS API. It has fields to describe the location (specifier + line + col) of an error, in addition to storing the error message.
- Loading branch information
1 parent
3eee9d3
commit 17affaa
Showing
10 changed files
with
324 additions
and
128 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { build, Parser } from "./mod.ts"; | ||
import { build, EszipError, Parser } from "./mod.ts"; | ||
import { | ||
assert, | ||
assertEquals, | ||
assertRejects, | ||
} from "https://deno.land/std@0.123.0/testing/asserts.ts"; | ||
} from "https://deno.land/std@0.155.0/testing/asserts.ts"; | ||
|
||
Deno.test("roundtrip build + parse", async () => { | ||
const eszip = await build([ | ||
|
@@ -60,7 +60,11 @@ Deno.test("build default loader", async () => { | |
}); | ||
|
||
Deno.test("build with import map", async () => { | ||
const eszip = await build(["data:application/javascript,import 'std/fs/mod.ts'"], undefined, "data:application/json,{\"imports\":{\"std/\":\"https://deno.land/std/\"}}"); | ||
const eszip = await build( | ||
["data:application/javascript,import 'std/fs/mod.ts'"], | ||
undefined, | ||
'data:application/json,{"imports":{"std/":"https://deno.land/std/"}}', | ||
); | ||
assert(eszip instanceof Uint8Array); | ||
}); | ||
|
||
|
@@ -71,7 +75,22 @@ Deno.test("loader errors", async () => { | |
["https://deno.land/[email protected]/fs/mod.ts"], | ||
(specifier: string) => Promise.reject(new Error("oops")), | ||
), | ||
undefined, | ||
Error, | ||
"oops", | ||
); | ||
}); | ||
|
||
Deno.test("eszip error", async () => { | ||
const err = await assertRejects( | ||
() => build(["file:///does/not/exist.ts"]), | ||
EszipError, | ||
); | ||
assertEquals( | ||
err.specifier, | ||
"file:///does/not/exist.ts", | ||
); | ||
assertEquals( | ||
err.message, | ||
"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
Binary file not shown.
Oops, something went wrong.