You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't forget that `vi.mock` call is hoisted to top of the file. **Do not** put `vi.mock` calls inside `beforeEach`, only one of these will actually mock a module.
You can set global variable by assigning a value to `globalThis` or using [`vi.stubGlobal`](/api/vi#vi-stubglobal) helper. When using `vi.stubGlobal`, it will **not** automatically reset between different tests, unless you enable [`unstubGlobals`](/config/#unstubglobals) config option or call [`vi.unstubAllGlobals`](/api/vi#vi-unstuballglobals).
1. To change environmental variable, you can just assign a new value to it.
647
650
648
-
To change environmental variable, you can just assign a new value to it. This value will **not** automatically reset between different tests.
651
+
::: warning
652
+
The environmental variable value will **_not_** automatically reset between different tests.
653
+
:::
649
654
650
655
```ts
651
656
import { beforeEach, expect, it } from'vitest'
@@ -663,7 +668,7 @@ it('changes value', () => {
663
668
})
664
669
```
665
670
666
-
If you want to automatically reset value, you can use `vi.stubEnv` helper with [`unstubEnvs`](/config/#unstubenvs) config option enabled (or call [`vi.unstubAllEnvs`](/api/vi#vi-unstuballenvs) manually in `beforeEach` hook):
671
+
2.If you want to automatically reset the value(s), you can use the `vi.stubEnv` helper with the [`unstubEnvs`](/config/#unstubenvs) config option enabled (or call [`vi.unstubAllEnvs`](/api/vi#vi-unstuballenvs) manually in a`beforeEach` hook):
0 commit comments