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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! MSW-style network-level request mocking for Reinhardt tests.
//!
//! On WASM targets, [`MockServiceWorker`] overrides `window.fetch()` in the
//! browser environment. On native targets, [`MockServiceWorker`] starts a
//! loopback HTTP mock server and exposes its base URL via
//! [`MockServiceWorker::url`].
//!
//! Native MSW is explicit endpoint injection, not transparent interception:
//! pass `worker.url()` into the HTTP client, SDK endpoint, or service
//! configuration under test.
//!
//! # WASM 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;
//! // Render component that calls window.fetch().
//! worker.calls_to("/api/users").assert_called();
//! }
//! ```
//!
//! # Native example
//!
//! ```rust,ignore
//! use reinhardt_test::msw::*;
//!
//! #[tokio::test]
//! async fn test_http_client() {
//! let worker = MockServiceWorker::new();
//! worker.handle(rest::get("/api/users").respond(MockResponse::json(vec![1, 2])));
//! worker.start().await;
//!
//! let endpoint = worker.url();
//! // Pass `endpoint` into the code under test.
//!
//! worker.calls_to("/api/users").assert_called();
//! worker.stop().await;
//! }
//! ```
// 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 MswError;
pub use InterceptedRequest;
pub use ;
pub use ;
pub use MockResponse;
pub use ;
pub use ;