Skip to content

Commit

Permalink
fix: don't reexport vi utils from vitest (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 5, 2022
1 parent b24fb25 commit 6f55275
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/index.ts
Expand Up @@ -7,7 +7,7 @@ export * from './runtime/hooks'

export { runOnce, isFirstRun } from './integrations/run-once'
export * from './integrations/chai'
export * from './integrations/spy'
export type { EnhancedSpy, SpyInstance, SpyInstanceFn, SpyContext } from './integrations/spy'
export * from './integrations/vi'
export * from './integrations/utils'

Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/integrations/vi.ts
Expand Up @@ -201,7 +201,7 @@ class VitestUtils {
* using jsdom/happy-dom and want to mock global variables, like
* `IntersectionObserver`.
*/
public stubGlobal(name: string, value: any) {
public stubGlobal(name: string | symbol | number, value: any) {
// @ts-expect-error we can do anything!
globalThis[name] = value
if (globalThis.window)
Expand Down
4 changes: 2 additions & 2 deletions test/core/test/spy.test.ts
@@ -1,12 +1,12 @@
import { describe, expect, spyOn, test } from 'vitest'
import { describe, expect, test, vi } from 'vitest'

/**
* @vitest-environment happy-dom
*/

describe('spyOn', () => {
test('correctly infers method types', async() => {
spyOn(localStorage, 'getItem').mockReturnValue('world')
vi.spyOn(localStorage, 'getItem').mockReturnValue('world')
expect(window.localStorage.getItem('hello')).toEqual('world')
})
})

0 comments on commit 6f55275

Please sign in to comment.