Skip to content

Commit

Permalink
chore: add version to "stubEnv" and "unstubAll"
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 16, 2022
1 parent 83707e7 commit 881bd7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/api/index.md
Expand Up @@ -2699,6 +2699,7 @@ Vitest provides utility functions to help you out through it's **vi** helper. Yo
### vi.stubEnv

- **Type:** `(name: string, value: string) => Vitest`
- **Version:** Since Vitest 0.26.0

Changes the value of environmental variable on `process.env` and `import.meta.env`. You can restore its value by calling `vi.unstubAllEnvs`.

Expand Down Expand Up @@ -2733,6 +2734,7 @@ But beware that you cannot rely on `import.meta.env.DEV === false` in this case.
### vi.unstubAllEnvs

- **Type:** `() => Vitest`
- **Version:** Since Vitest 0.26.0

Restores all `import.meta.env` and `process.env` values that were changed with `vi.stubEnv`. When it's called for the first time, Vitest remembers the original value and will store it, until `unstubAllEnvs` is called again.

Expand Down Expand Up @@ -2791,6 +2793,7 @@ window.innerWidth = 100
### vi.unstubAllGlobals

- **Type:** `() => Vitest`
- **Version:** Since Vitest 0.26.0

Restores all global values on `globalThis`/`global` (and `window`/`top`/`self`/`parent`, if you are using `jsdom` or `happy-dom` environment) that were changed with `vi.stubGlobal`. When it's called for the first time, Vitest remembers the original value and will store it, until `unstubAllGlobals` is called again.

Expand Down
2 changes: 2 additions & 0 deletions docs/config/index.md
Expand Up @@ -781,13 +781,15 @@ Will call [`.mockRestore()`](/api/#mockrestore) on all spies before each test. T

- **Type:** `boolean`
- **Default:** `false`
- **Version:** Since Vitest 0.26.0

Will call [`vi.unstubAllEnvs`](/api/#vi-unstuballenvs) before each test.

### unstubGlobals

- **Type:** `boolean`
- **Default:** `false`
- **Version:** Since Vitest 0.26.0

Will call [`vi.unstubAllGlobals`](/api/#vi-unstuballglobals) before each test.

Expand Down

0 comments on commit 881bd7a

Please sign in to comment.