Skip to content

test: replace deprecated toMatchTypeOf #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"svelte-check": "^3.0.0 || ^4.0.4",
"svelte-jester": "^5.0.0",
"typescript": "^5.5.3",
"typescript-svelte-plugin": "^0.3.46",
"vite": "^4.0.0 || ^5.3.3",
"vitest": "0.x.x || ^1.0.0 || ^2.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/render-runes.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('types', () => {
test('render result has container and component', () => {
const result = subject.render(Component, { name: 'Alice', count: 42 })

expectTypeOf(result).toMatchTypeOf<{
expectTypeOf(result).toExtend<{
container: HTMLElement
component: { hello: string }
debug: (el?: HTMLElement) => void
Expand All @@ -55,7 +55,7 @@ describe('legacy component types', () => {
count: 42,
})

expectTypeOf(component).toMatchTypeOf<{ hello: string }>()
expectTypeOf(component).toExtend<{ hello: string }>()

// @ts-expect-error: Svelte 5 mount does not return `$set`
component.$on('greeting', onGreeting)
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/render-utilities.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('render query and utility types', () => {
test('render result has default queries', () => {
const result = subject.render(Component, { name: 'Alice' })

expectTypeOf(result.getByRole).parameters.toMatchTypeOf<
expectTypeOf(result.getByRole).parameters.toExtend<
[role: subject.ByRoleMatcher, options?: subject.ByRoleOptions]
>()
})
Expand All @@ -27,25 +27,25 @@ describe('render query and utility types', () => {
{ queries: { getByVibes } }
)

expectTypeOf(result.getByVibes).parameters.toMatchTypeOf<[vibes: string]>()
expectTypeOf(result.getByVibes).parameters.toExtend<[vibes: string]>()
})

test('act is an async function', () => {
expectTypeOf(subject.act).toMatchTypeOf<() => Promise<void>>()
expectTypeOf(subject.act).toExtend<() => Promise<void>>()
})

test('act accepts a sync function', () => {
expectTypeOf(subject.act).toMatchTypeOf<(fn: () => void) => Promise<void>>()
expectTypeOf(subject.act).toExtend<(fn: () => void) => Promise<void>>()
})

test('act accepts an async function', () => {
expectTypeOf(subject.act).toMatchTypeOf<
expectTypeOf(subject.act).toExtend<
(fn: () => Promise<void>) => Promise<void>
>()
})

test('fireEvent is an async function', () => {
expectTypeOf(subject.fireEvent).toMatchTypeOf<
expectTypeOf(subject.fireEvent).toExtend<
(
element: Element | Node | Document | Window,
event: Event
Expand All @@ -54,7 +54,7 @@ describe('render query and utility types', () => {
})

test('fireEvent[eventName] is an async function', () => {
expectTypeOf(subject.fireEvent.click).toMatchTypeOf<
expectTypeOf(subject.fireEvent.click).toExtend<
(
element: Element | Node | Document | Window,
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/render.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('types', () => {
test('render result has container and component', () => {
const result = subject.render(Component, { name: 'Alice', count: 42 })

expectTypeOf(result).toMatchTypeOf<{
expectTypeOf(result).toExtend<{
container: HTMLElement
component: { hello: string }
debug: (el?: HTMLElement) => void
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"noEmit": true,
"skipLibCheck": true,
"strict": true,
"types": ["svelte", "vite/client", "vitest", "vitest/globals"]
"types": ["svelte", "vite/client", "vitest", "vitest/globals"],
"plugins": [{ "name": "typescript-svelte-plugin" }]
},
"include": ["src"]
}