mock-xmlhttprequest
Version:
XMLHttpRequest mock for testing
24 lines (22 loc) • 940 B
text/typescript
/**
* mock-xmlhttprequest v8.4.1
* (c) 2025 Bertrand Guay-Paquet
* @license MIT
*/
import MockXhr from './MockXhr.cts';
import MockXhrServer from './MockXhrServer.cts';
import type { UrlMatcher, RequestHandler } from './MockXhrServer.cts';
/**
* Create a new "local" MockXhr subclass. Using a subclass of `MockXhr` in each test case makes it
* easier to ensure they are self-contained. For example if you set the onSend static property on
* a subclass, this will only affect that subclass and not the others created in your other test
* cases. You therefore don't need to add cleanup code to revert the changes made to the subclass.
*
* @returns New MockXhr subclass
*/
export declare function newMockXhr(): typeof MockXhr;
/**
* @param routes Routes
* @returns new MockXhrServerserver with its own MockXhr subclass.
*/
export declare function newServer(routes?: Record<string, [UrlMatcher, RequestHandler]>): MockXhrServer;