Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { isVue2, isVue3, ref } from 'vue-demi'
import { environmentManager } from '@tanstack/query-core'
import { queryKey } from '@tanstack/query-test-utils'
import { QueryClient } from '../queryClient'
import { VueQueryPlugin } from '../vueQueryPlugin'
Expand Down Expand Up @@ -218,6 +219,19 @@ describe('VueQueryPlugin', () => {
customClient,
)
})

it('should not mount client when in a server environment', () => {
environmentManager.setIsServer(() => true)
try {
const appMock = getAppMock()
const customClient = { mount: vi.fn() } as unknown as QueryClient
VueQueryPlugin.install(appMock, { queryClient: customClient })

expect(customClient.mount).not.toHaveBeenCalled()
} finally {
environmentManager.setIsServer(() => false)
}
})
})

describe('when called with custom client config', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/vue-query/src/vueQueryPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isVue2 } from 'vue-demi'
import { isServer } from '@tanstack/query-core'
import { environmentManager } from '@tanstack/query-core'

import { QueryClient } from './queryClient'
import { getClientKey } from './utils'
Expand Down Expand Up @@ -38,7 +38,7 @@ export const VueQueryPlugin = {
client = new QueryClient(clientConfig)
}

if (!isServer) {
if (!environmentManager.isServer()) {
client.mount()
}

Expand Down