replace msw with setupRequestMockHandlers
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
@@ -14,8 +14,6 @@ export type CollectedLogs<T extends LogFuncs> = {
|
||||
[key in T]: string[];
|
||||
};
|
||||
|
||||
// Warning: (tsdoc-missing-deprecation-message) The @deprecated block must include a deprecation message, e.g. describing the recommended alternative
|
||||
//
|
||||
// @public @deprecated (undocumented)
|
||||
export class Keyboard {
|
||||
constructor(
|
||||
|
||||
@@ -146,9 +146,7 @@ export type MockStorageBucket = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
// Warning: (ae-missing-release-tag) "msw" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
// @public @deprecated (undocumented)
|
||||
export const msw: {
|
||||
setupDefaultHandlers: (worker: {
|
||||
listen: (t: any) => void;
|
||||
@@ -166,6 +164,13 @@ export function renderInTestApp(
|
||||
// @public
|
||||
export function renderWithEffects(nodes: ReactElement): Promise<RenderResult>;
|
||||
|
||||
// @public
|
||||
export function setupRequestMockHandlers(worker: {
|
||||
listen: (t: any) => void;
|
||||
close: () => void;
|
||||
resetHandlers: () => void;
|
||||
}): void;
|
||||
|
||||
// @public
|
||||
export type SyncLogCollector = () => void;
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated use {@link setupRequestMockHandlers} instead which can be called directly with the worker.
|
||||
* @public
|
||||
*/
|
||||
export const msw = {
|
||||
setupDefaultHandlers: (worker: {
|
||||
listen: (t: any) => void;
|
||||
@@ -25,3 +29,18 @@ export const msw = {
|
||||
afterEach(() => worker.resetHandlers());
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets up handlers for request mocking
|
||||
* @public
|
||||
* @param worker - service worker
|
||||
*/
|
||||
export function setupRequestMockHandlers(worker: {
|
||||
listen: (t: any) => void;
|
||||
close: () => void;
|
||||
resetHandlers: () => void;
|
||||
}) {
|
||||
beforeAll(() => worker.listen({ onUnhandledRequest: 'error' }));
|
||||
afterAll(() => worker.close());
|
||||
afterEach(() => worker.resetHandlers());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user