1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! MSW-style network-level request interception for WASM testing.
//!
//! Intercepts `window.fetch()` calls at the browser API level, providing
//! realistic API mocking without modifying application code.
//!
//! # Overview
//!
//! This module provides `MockServiceWorker` which overrides `window.fetch`
//! to intercept HTTP requests and return mock responses. It supports:
//!
//! - Type-safe `server_fn` mocking via `MockableServerFn`
//! - REST endpoint mocking via [`rest`] builder helpers
//! - Request recording and assertion via `CallQuery` and `ServerFnCallQuery`
//! - Configurable behavior for unhandled requests via `UnhandledPolicy`
//!
//! # Example
//!
//! ```rust,ignore
//! use reinhardt_test::msw::*;
//!
//! #[wasm_bindgen_test]
//! async fn test_component() {
//! let worker = MockServiceWorker::new();
//! worker.handle(rest::get("/api/users").respond(MockResponse::json(vec![1, 2])));
//! worker.start().await;
//! // ... test component ...
//! worker.calls_to("/api/users").assert_called();
//! }
//! ```
// On native builds, worker.rs and interceptor.rs are behind #[cfg(wasm)],
// making handler/recorder/context types appear unused in lib mode.
// They ARE exercised in WASM builds and native unit tests.
pub
pub
pub use TestContext;
pub use InterceptedRequest;
pub use ;
pub use ;
pub use MockResponse;
// WASM-only: MockServiceWorker requires window.fetch interop
pub use ;