Open History to see the last commit
1<script lang="ts">
2 import { sleep } from '@tanstack/query-test-utils'
3 import { createMutation, setQueryClientContext } from '../../src/index.js'
4 import type { QueryClient } from '@tanstack/query-core'
5β
6 type Props = {
7 queryClient: QueryClient
8 }
9β
10 let { queryClient }: Props = $props()
11β
12 setQueryClientContext(queryClient)
13β
14 const mutation = createMutation(() => ({
15 mutationFn: () =>
16 sleep(10).then(() => Promise.reject(new Error('Expected mock error'))),
17 }))
18</script>
19β
20<button onclick={() => mutation.reset()}>Reset</button>
21<button onclick={() => mutation.mutate()}>Mutate</button>
22β
23<div>Error: {mutation.error?.message ?? 'undefined'}</div>