Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/breezy-cobras-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/solid-query-devtools': patch
---

Fixed client prop not working on SolidQueryDevtools and SolidQueryDevtoolsPanel
3 changes: 3 additions & 0 deletions packages/solid-query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
"test:build": "publint --strict && attw --pack",
"test:lib": "vitest --retry=3",
"test:lib:dev": "pnpm run test:lib --watch",
"build": "tsup --tsconfig tsconfig.prod.json",
"build:dev": "tsup --watch"
},
Expand Down Expand Up @@ -64,6 +66,7 @@
"@tanstack/query-devtools": "workspace:*"
},
"devDependencies": {
"@solidjs/testing-library": "^0.8.10",
"@tanstack/solid-query": "workspace:*",
"npm-run-all2": "^5.0.0",
"solid-js": "^1.9.7",
Expand Down
32 changes: 32 additions & 0 deletions packages/solid-query-devtools/src/__tests__/devtools.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import { render } from '@solidjs/testing-library'
import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'
import SolidQueryDevtools from '../devtools'

describe('SolidQueryDevtools', () => {
it('should throw an error if no query client has been set', () => {
expect(() => render(() => <SolidQueryDevtools />)).toThrow(
'No QueryClient set, use QueryClientProvider to set one',
)
})

it('should not throw an error if query client is provided via context', () => {
const queryClient = new QueryClient()

expect(() =>
render(() => (
<QueryClientProvider client={queryClient}>
<SolidQueryDevtools />
</QueryClientProvider>
)),
).not.toThrow()
})

it('should not throw an error if query client is provided via props', () => {
const queryClient = new QueryClient()

expect(() =>
render(() => <SolidQueryDevtools client={queryClient} />),
).not.toThrow()
})
})
32 changes: 32 additions & 0 deletions packages/solid-query-devtools/src/__tests__/devtoolsPanel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import { render } from '@solidjs/testing-library'
import { QueryClient, QueryClientProvider } from '@tanstack/solid-query'
import SolidQueryDevtoolsPanel from '../devtoolsPanel'

describe('SolidQueryDevtoolsPanel', () => {
it('should throw an error if no query client has been set', () => {
expect(() => render(() => <SolidQueryDevtoolsPanel />)).toThrow(
'No QueryClient set, use QueryClientProvider to set one',
)
})

it('should not throw an error if query client is provided via context', () => {
const queryClient = new QueryClient()

expect(() =>
render(() => (
<QueryClientProvider client={queryClient}>
<SolidQueryDevtoolsPanel />
</QueryClientProvider>
)),
).not.toThrow()
})

it('should not throw an error if query client is provided via props', () => {
const queryClient = new QueryClient()

expect(() =>
render(() => <SolidQueryDevtoolsPanel client={queryClient} />),
).not.toThrow()
})
})
4 changes: 2 additions & 2 deletions packages/solid-query-devtools/src/devtools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ interface DevtoolsOptions {
}

export default function SolidQueryDevtools(props: DevtoolsOptions) {
const queryClient = useQueryClient()
const client = createMemo(() => props.client || queryClient)
const queryClient = useQueryClient(props.client)
const client = createMemo(() => queryClient)
let ref!: HTMLDivElement
const devtools = new TanstackQueryDevtools({
client: client(),
Expand Down
4 changes: 2 additions & 2 deletions packages/solid-query-devtools/src/devtoolsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export interface DevtoolsPanelOptions {
}

export default function SolidQueryDevtoolsPanel(props: DevtoolsPanelOptions) {
const queryClient = useQueryClient()
const client = createMemo(() => props.client || queryClient)
const queryClient = useQueryClient(props.client)
const client = createMemo(() => queryClient)
let ref!: HTMLDivElement
const { errorTypes, styleNonce, shadowDOMTarget, hideDisabledQueries } = props
const devtools = new TanstackQueryDevtoolsPanel({
Expand Down
6 changes: 6 additions & 0 deletions packages/solid-query-devtools/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom/vitest'
import { cleanup } from '@solidjs/testing-library'
import { afterEach } from 'vitest'

// https://github.com/solidjs/solid-testing-library
afterEach(() => cleanup())
12 changes: 12 additions & 0 deletions packages/solid-query-devtools/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig } from 'vite'
import solid from 'vite-plugin-solid'

import packageJson from './package.json'

export default defineConfig({
plugins: [solid()],
// fix from https://github.com/vitest-dev/vitest/issues/6992#issuecomment-2509408660
Expand All @@ -14,4 +16,14 @@ export default defineConfig({
},
},
},
test: {
name: packageJson.name,
dir: './src',
watch: false,
environment: 'jsdom',
setupFiles: ['test-setup.ts'],
coverage: { enabled: true, provider: 'istanbul', include: ['src/**/*'] },
typecheck: { enabled: true },
restoreMocks: true,
},
})
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading