-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
cacb608
commit 988312f
Showing
3 changed files
with
34 additions
and
56 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { GlobalSetupContext } from "vitest/node"; | ||
|
||
export default function setup({ provide }: GlobalSetupContext): void { | ||
const runtime = process.env.JS_RUNTIME; | ||
|
||
switch (runtime) { | ||
case "deno": { | ||
// @ts-expect-error - Ignore the global object | ||
if (!global.Deno) { | ||
throw new Error("Not valid deno runtime available"); | ||
} | ||
break; | ||
} | ||
case "node": { | ||
if (!global.process) { | ||
throw new Error("Not valid js runtime available"); | ||
} | ||
break; | ||
} | ||
default: | ||
throw new Error( | ||
`Not valid deno runtime available "${runtime}". Possible options are deno | node` | ||
); | ||
} | ||
|
||
provide("runtime", runtime); | ||
} | ||
|
||
declare module "vitest" { | ||
export interface ProvidedContext { | ||
runtime: "deno" | "node"; | ||
} | ||
} |