Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

test-utils.ts

24 lines790 Bytes

1import { provideZonelessChangeDetection } from '@angular/core'
2import { TestBed } from '@angular/core/testing'
3import { vi } from 'vitest'
4import { provideTanStackQuery } from '@tanstack/angular-query-experimental'
5import type { QueryClient } from '@tanstack/query-core'
6import type { EnvironmentProviders, Provider } from '@angular/core'
7​
8export function setupTanStackQueryTestBed(
9 queryClient: QueryClient,
10 options: { providers?: Array<Provider | EnvironmentProviders> } = {},
11) {
12 TestBed.resetTestingModule()
13 TestBed.configureTestingModule({
14 providers: [
15 provideZonelessChangeDetection(),
16 ...provideTanStackQuery(queryClient),
17 ...(options.providers ?? []),
18 ],
19 })
21​
22export async function flushQueryUpdates() {
23 await vi.advanceTimersByTimeAsync(0)