pub struct NetworkInterception { /* private fields */ }Expand description
Network interception handler
Implementations§
Source§impl NetworkInterception
impl NetworkInterception
Sourcepub const fn capture_all(self) -> Self
pub const fn capture_all(self) -> Self
Enable capturing all requests
Sourcepub const fn block_unmatched(self) -> Self
pub const fn block_unmatched(self) -> Self
Block unmatched requests
Sourcepub fn get(&mut self, pattern: &str, response: MockResponse)
pub fn get(&mut self, pattern: &str, response: MockResponse)
Add a GET route
Sourcepub fn post(&mut self, pattern: &str, response: MockResponse)
pub fn post(&mut self, pattern: &str, response: MockResponse)
Add a POST route
Sourcepub fn put(&mut self, pattern: &str, response: MockResponse)
pub fn put(&mut self, pattern: &str, response: MockResponse)
Add a PUT route
Sourcepub fn delete(&mut self, pattern: &str, response: MockResponse)
pub fn delete(&mut self, pattern: &str, response: MockResponse)
Add a DELETE route
Sourcepub fn handle_request(
&mut self,
url: &str,
method: HttpMethod,
headers: HashMap<String, String>,
body: Option<Vec<u8>>,
) -> Option<MockResponse>
pub fn handle_request( &mut self, url: &str, method: HttpMethod, headers: HashMap<String, String>, body: Option<Vec<u8>>, ) -> Option<MockResponse>
Handle an incoming request
Sourcepub fn captured_requests(&self) -> Vec<CapturedRequest>
pub fn captured_requests(&self) -> Vec<CapturedRequest>
Get all captured requests
Sourcepub fn requests_matching(&self, pattern: &UrlPattern) -> Vec<CapturedRequest>
pub fn requests_matching(&self, pattern: &UrlPattern) -> Vec<CapturedRequest>
Get captured requests matching a URL pattern
Sourcepub fn requests_by_method(&self, method: HttpMethod) -> Vec<CapturedRequest>
pub fn requests_by_method(&self, method: HttpMethod) -> Vec<CapturedRequest>
Get captured requests by method
Sourcepub fn assert_requested(&self, pattern: &UrlPattern) -> ProbarResult<()>
pub fn assert_requested(&self, pattern: &UrlPattern) -> ProbarResult<()>
Assert a request was made
Sourcepub fn assert_requested_times(
&self,
pattern: &UrlPattern,
times: usize,
) -> ProbarResult<()>
pub fn assert_requested_times( &self, pattern: &UrlPattern, times: usize, ) -> ProbarResult<()>
Assert a request was made N times
Sourcepub fn assert_not_requested(&self, pattern: &UrlPattern) -> ProbarResult<()>
pub fn assert_not_requested(&self, pattern: &UrlPattern) -> ProbarResult<()>
Assert no requests were made matching a pattern
Sourcepub fn clear_captured(&self)
pub fn clear_captured(&self)
Clear captured requests
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Get route count
Sourcepub fn clear_routes(&mut self)
pub fn clear_routes(&mut self)
Clear all routes
Sourcepub fn abort(&mut self, pattern: &str, reason: AbortReason)
pub fn abort(&mut self, pattern: &str, reason: AbortReason)
Abort requests matching a pattern with a specific reason
Per Playwright: page.route('**/api/*', route => route.abort())
Sourcepub fn abort_pattern(&mut self, pattern: UrlPattern, reason: AbortReason)
pub fn abort_pattern(&mut self, pattern: UrlPattern, reason: AbortReason)
Abort requests matching a pattern (default reason: Aborted)
Sourcepub fn find_request(&self, pattern: &UrlPattern) -> Option<CapturedRequest>
pub fn find_request(&self, pattern: &UrlPattern) -> Option<CapturedRequest>
Wait for a request matching a pattern (synchronous check)
Per Playwright: page.waitForRequest(url)
Sourcepub fn find_response_for(&self, pattern: &UrlPattern) -> Option<MockResponse>
pub fn find_response_for(&self, pattern: &UrlPattern) -> Option<MockResponse>
Wait for a response matching a pattern (returns the response from route)
Per Playwright: page.waitForResponse(url)
Sourcepub fn was_aborted(&self, pattern: &UrlPattern) -> bool
pub fn was_aborted(&self, pattern: &UrlPattern) -> bool
Check if a request was aborted
Sourcepub fn captured_responses(&self) -> Vec<MockResponse>
pub fn captured_responses(&self) -> Vec<MockResponse>
Get captured responses (mock responses that were returned)
Trait Implementations§
Source§impl Debug for NetworkInterception
impl Debug for NetworkInterception
Auto Trait Implementations§
impl Freeze for NetworkInterception
impl RefUnwindSafe for NetworkInterception
impl Send for NetworkInterception
impl Sync for NetworkInterception
impl Unpin for NetworkInterception
impl UnsafeUnpin for NetworkInterception
impl UnwindSafe for NetworkInterception
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().