docs(aio): update docs error in guide/http (#23567)
Updates documentation to include examples for both req.flush and req.error in http testing examples. PR Close #23567
This commit is contained in:
		
							parent
							
								
									4cb46ce10c
								
							
						
					
					
						commit
						cc6c4346c2
					
				| @ -150,7 +150,7 @@ describe('HttpClient testing', () => { | |||||||
| 
 | 
 | ||||||
|     // Create mock ErrorEvent, raised when something goes wrong at the network level.
 |     // Create mock ErrorEvent, raised when something goes wrong at the network level.
 | ||||||
|     // Connection timeout, DNS error, offline, etc
 |     // Connection timeout, DNS error, offline, etc
 | ||||||
|     const errorEvent = new ErrorEvent('so sad', { |     const mockError = new ErrorEvent('Network error', { | ||||||
|       message: emsg, |       message: emsg, | ||||||
|       // #enddocregion network-error
 |       // #enddocregion network-error
 | ||||||
|       // The rest of this is optional and not used.
 |       // The rest of this is optional and not used.
 | ||||||
| @ -162,7 +162,7 @@ describe('HttpClient testing', () => { | |||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // Respond with mock error
 |     // Respond with mock error
 | ||||||
|     req.error(errorEvent); |     req.error(mockError); | ||||||
|   }); |   }); | ||||||
|   // #enddocregion network-error
 |   // #enddocregion network-error
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1030,10 +1030,18 @@ you are responsible for flushing and verifying them. | |||||||
| 
 | 
 | ||||||
| You should test the app's defenses against HTTP requests that fail. | You should test the app's defenses against HTTP requests that fail. | ||||||
| 
 | 
 | ||||||
| Call `request.error()` with an `ErrorEvent` instead of `request.flush()`, as in this example. | Call `request.flush()` with an error message, as seen in the following example. | ||||||
| 
 | 
 | ||||||
| <code-example  | <code-example  | ||||||
|   path="http/src/testing/http-client.spec.ts" |   path="http/src/testing/http-client.spec.ts" | ||||||
|   region="404"  |   region="404"  | ||||||
|   linenums="false"> |   linenums="false"> | ||||||
| </code-example> | </code-example> | ||||||
|  | 
 | ||||||
|  | Alternatively, you can call `request.error()` with an `ErrorEvent`. | ||||||
|  | 
 | ||||||
|  | <code-example | ||||||
|  |   path="http/src/testing/http-client.spec.ts" | ||||||
|  |   region="network-error" | ||||||
|  |   linenums="false"> | ||||||
|  | </code-example> | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user