/** Which checks {@link enableAngularDiagnostics} installs. Every member defaults to `true`. */ interface AngularDiagnosticsOptions { /** * Fail when a testing module imports an NgModule that contributes nothing at runtime — the AOT * bundle that dropped `ɵɵsetNgModuleScope`, checked automatically instead of by hand. */ ngModuleScopes?: boolean; /** Fail when `schemas` are configured next to a standalone component, where they can never apply. */ deadSchemas?: boolean; /** Fail — rather than warn — when `injectSpy` finds a real instance where a spy was expected. */ unspiedProviders?: boolean; /** Fail a test that ends with unflushed `HttpTestingController` requests. */ pendingRequests?: boolean; /** * Fail when a double registered on the testing module loses to the component's own `providers`, * so the component under test is running against the real service. */ shadowedProviders?: boolean; } /** * Fail when the `HttpTestingController` this test configured is still holding requests. * * `pendingRequests` runs this after every test; it is exported because the same question is worth * asking mid-test — after the arrange step, before the assertions that depend on it — and because * reading it takes the requests, so calling it yourself is not paid for twice. * * A no-op when the group is off, or when the test never configured HTTP testing at all. * * @example * ```ts * facade.load(); * controller.expectOne('/api/users').flush([]); * assertNoPendingRequests(); // nothing else went out * ``` */ declare function assertNoPendingRequests(): void; /** * Fail when a double this test registered on the testing module never reached `component`. * * `shadowedProviders` calls this on every fixture; it is exported for the same reason * {@link assertNoPendingRequests} is — a spec that builds its component through a helper of its own * can ask directly, and a check that can only be reached through one code path is a check that * stops running the day that path changes. * * A no-op when the fixture never rendered `component`, and when everything it resolved is a double. * * @example * ```ts * const fixture = renderThroughOurHelper(CartComponent); * assertNoShadowedProviders(CartComponent, fixture); // the doubles really are the ones in play * ``` */ declare function assertNoShadowedProviders(component: unknown, fixture: unknown): void; /** * Turn the group on. Every member defaults to `true`; pass `false` to leave one out. * * ```ts * enableAngularDiagnostics({ unspiedProviders: false }); // the other three * ``` * * Calling it again replaces the previous selection rather than adding to it. */ declare function enableAngularDiagnostics(options?: AngularDiagnosticsOptions): void; /** * Turn the group off: no more configuration inspection, and `injectSpy` warns again instead of * failing. * * The `TestBed` timing instrumentation is left in place — `enableTestBedDiagnostics` may be using * it, it is idempotent, and `disableTestBedDiagnostics()` is what removes it. */ declare function disableAngularDiagnostics(): void; /** What one spec file cost. */ interface SpecTiming { /** Absolute path of the spec file, or `'unknown file'` when the runner did not report one. */ file: string; /** Wall-clock time spent inside the instrumented `TestBed` calls. */ testBedMs: number; /** Wall-clock time of the whole file. */ totalMs: number; /** `totalMs - testBedMs` — the part that is plain TypeScript. */ otherMs: number; /** How many components the file created. */ components: number; /** How many testing modules it configured. */ configurations: number; } /** Options for {@link enableTestBedDiagnostics}. */ interface TestBedDiagnosticsOptions { /** Receives each file's timing. Defaults to one `console.info` line per file. */ report?: (timing: SpecTiming) => void; /** Stay quiet for files whose `testBedMs` is below this. Default `0` (report every file). */ minTestBedMs?: number; } /** * Wrap the `TestBed` entry points — on the instance, which every static delegates to. Idempotent, * and safe on Angular versions missing one of them. * * @example * ```ts * instrumentTestBed(); // start measuring; pair with getTestBedTiming() in an afterAll * ``` */ declare function instrumentTestBed(): void; /** * Undo the instrumentation, putting the original `TestBed` methods back. * * @example * ```ts * disableTestBedDiagnostics(); // put the untouched TestBed back * ``` */ declare function disableTestBedDiagnostics(): void; /** * The timing accumulated so far in the current file. * * @example * ```ts * afterAll(() => { * const timing = getTestBedTiming(); * * if (timing.testBedMs > 200) { * reportSpecTiming(timing); * } * }); * ``` */ declare function getTestBedTiming(): SpecTiming; /** * One human-readable line: what the file cost and how much of it was `TestBed`. * * @example * ```ts * process.stdout.write(`${formatSpecTiming(getTestBedTiming())}\n`); * ``` */ declare function formatSpecTiming(timing: SpecTiming): string; /** * Write the report where a test run can actually show it. * * Not `console.info`: a project that imports `vitest-auto-spy/console` (or spies the console for * any other reason) has replaced that method with a silent mock, and the report would vanish — * which is exactly what happened the first time these diagnostics were pointed at a real suite. * * Exported as the default `report`: a project that wants both its own bookkeeping and the printed * line can call it from a custom reporter. * * @example * ```ts * reportSpecTiming(getTestBedTiming()); // one line to process.stdout, not console.info * ``` */ declare function reportSpecTiming(timing: SpecTiming): void; /** * Instrument `TestBed` and report each spec file's cost. * * ```ts * // vitest.setup.ts * import { enableTestBedDiagnostics } from 'vitest-auto-spy/angular/diagnostics'; * * if (process.env['SPEC_TIMING']) { * enableTestBedDiagnostics(); * } * ``` */ declare function enableTestBedDiagnostics(options?: TestBedDiagnosticsOptions): void; export { type AngularDiagnosticsOptions, type SpecTiming, type TestBedDiagnosticsOptions, assertNoPendingRequests, assertNoShadowedProviders, disableAngularDiagnostics, disableTestBedDiagnostics, enableAngularDiagnostics, enableTestBedDiagnostics, formatSpecTiming, getTestBedTiming, instrumentTestBed, reportSpecTiming };