Skip to content

Commit

Permalink
tests: Use recommended @testing-library/svelte setup (#7645)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Jun 29, 2024
1 parent 87c8e01 commit 003e1a8
Show file tree
Hide file tree
Showing 27 changed files with 98 additions and 39 deletions.
3 changes: 0 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ export default [
],
'ts/ban-types': 'off',
'ts/no-empty-function': 'off',
'ts/require-await': 'off',
'no-case-declarations': 'off',
'no-empty': 'off',
'no-prototype-builtins': 'off',
},
},
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@cspell/eslint-plugin": "^8.9.1",
"@eslint-react/eslint-plugin": "^1.5.16",
"@solidjs/testing-library": "^0.8.8",
"@tanstack/config": "^0.8.6",
"@tanstack/config": "^0.9.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/node": "^20.12.12",
Expand Down
1 change: 1 addition & 0 deletions packages/svelte-query-devtools/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"src/**/*.ts",
"src/**/*.svelte",
"eslint.config.js",
"svelte.config.js",
"vite.config.ts"
]
}
6 changes: 0 additions & 6 deletions packages/svelte-query-persist-client/test-setup.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import AwaitOnSuccess from './AwaitOnSuccess.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import FreshData from './FreshData.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import InitialData from './InitialData.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import OnSuccess from './OnSuccess.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import RemoveCache from './RemoveCache.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import RestoreCache from './RestoreCache.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import PersistQueryClientProvider from '../../PersistQueryClientProvider.svelte'
import PersistQueryClientProvider from '../../src/PersistQueryClientProvider.svelte'
import UseQueries from './UseQueries.svelte'
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
Expand Down
1 change: 1 addition & 0 deletions packages/svelte-query-persist-client/tests/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/vitest'
5 changes: 4 additions & 1 deletion packages/svelte-query-persist-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
"src/**/*.js",
"src/**/*.ts",
"src/**/*.svelte",
"tests/**/*.js",
"tests/**/*.ts",
"tests/**/*.svelte",
"eslint.config.js",
"test-setup.ts",
"svelte.config.js",
"vite.config.ts"
]
}
7 changes: 4 additions & 3 deletions packages/svelte-query-persist-client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { defineConfig } from 'vitest/config'
import { svelteTesting } from '@testing-library/svelte/vite'
import packageJson from './package.json'

export default defineConfig({
plugins: [svelte()],
plugins: [svelte(), svelteTesting()],
test: {
name: packageJson.name,
dir: './src',
dir: './tests',
watch: false,
environment: 'jsdom',
setupFiles: ['test-setup.ts'],
setupFiles: ['./tests/test-setup.ts'],
coverage: { enabled: true, provider: 'istanbul', include: ['src/**/*'] },
typecheck: { enabled: true },
restoreMocks: true,
Expand Down
5 changes: 0 additions & 5 deletions packages/svelte-query/tests/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
import '@testing-library/jest-dom/vitest'
import { cleanup } from '@testing-library/svelte'
import { afterEach } from 'vitest'

// https://testing-library.com/docs/svelte-testing-library/api/#cleanup
afterEach(() => cleanup())
1 change: 1 addition & 0 deletions packages/svelte-query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"tests/**/*.ts",
"tests/**/*.svelte",
"eslint.config.js",
"svelte.config.js",
"vite.config.ts"
]
}
3 changes: 2 additions & 1 deletion packages/svelte-query/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { defineConfig } from 'vitest/config'
import { svelteTesting } from '@testing-library/svelte/vite'
import packageJson from './package.json'

export default defineConfig({
plugins: [svelte()],
plugins: [svelte(), svelteTesting()],
test: {
name: packageJson.name,
dir: './tests',
Expand Down
89 changes: 77 additions & 12 deletions pnpm-lock.yaml

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

0 comments on commit 003e1a8

Please sign in to comment.