docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Utility for controlling outbound HTTP usage during tests by gating real network traffic and toggling interceptors.
block with allowlist ["allowed.test"], a GET request to http://blocked.test/resource is rejected while http://allowed.test/ping proceeds. @testallowAll lets real requests through even after block was invoked, until blocking is re-applied. @testdeactivate lets real requests bypass interceptors without clearing existing mock definitions; calling activate afterwards restores interception for the same mocks. @testisActive reflects hook status before and after deactivate/activate calls. @testexport interface AllowMatcher {
(host: string): boolean;
}
export type AllowRule = string | RegExp | AllowMatcher;
export interface NetworkGuardOptions {
allow?: AllowRule | AllowRule[];
}
export interface NetworkGuard {
block(allow?: AllowRule | AllowRule[]): void;
allowAll(): void;
deactivate(): void;
activate(): void;
isActive(): boolean;
}
export function createNetworkGuard(options?: NetworkGuardOptions): NetworkGuard;HTTP interception and network gating for Node.js tests.