-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: leverage ES Modules in tests (#208)
* refactor: remove embedded Deno assert bundle We can import the vendored module using a relative path now. * refactor: extract `test(name, fn)` helper Move the function creating isolated scopes for individual tests into the `helpers.js` and use this new shared helper in all tests. --------- Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
- Loading branch information
Showing
11 changed files
with
39 additions
and
90 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
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,23 @@ | ||
// A dummy wrapper to create isolated scopes for individual tests | ||
// We should eventually replace this with a proper test runner | ||
// See https://github.com/filecoin-station/zinnia/issues/30 | ||
export function test(name, fn) { | ||
let maybePromise; | ||
try { | ||
maybePromise = fn(); | ||
} catch { | ||
err.message = `Test ${name} failed. ` + err.message; | ||
throw err; | ||
} | ||
|
||
if (typeof maybePromise?.then !== "function") { | ||
// The test fn was synchronous, we are done. | ||
return maybePromise; | ||
} | ||
|
||
// The test fn returned a promise, we need to wait for completion | ||
return maybePromise.catch((err) => { | ||
err.message = `Test ${name} failed. ` + err.message; | ||
throw err; | ||
}); | ||
} |
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
File renamed without changes.
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