Testing
Testing utilities for mock server setup and Vitest integration.
Examples (7)
Section titled “Examples (7)”| Example | Description |
|---|---|
| Configuration Constants | This example demonstrates the configuration constants available in the used to configure mock servers for testing Algorand client integrations. No mock server is required - this example just displays the constants. |
| Test Data Constants | This example demonstrates the test data constants available in the the pre-recorded HAR file responses used by the mock server. No mock server is required - this example just displays the constants. |
| Health Check Utility | This example demonstrates how to use checkServerHealth() to verify mock server availability before running tests. The function checks if a server is reachable by performing a health check request. This example works whether or not mock servers are running - it just reports the status of each server. |
| Mock Server Connection | This example demonstrates how to use getMockServer() to connect to a mock server and understand the MockServer interface. It shows:
This example requires MOCK_ALGOD_URL environment variable and a running mock server for a successful connection - otherwise it shows helpful error messages. |
| Vitest Global Setup Factory | This example demonstrates how to use createGlobalSetup() to create custom Vitest global setup functions for mock server lifecycle management. It shows:
NOTE: This example documents the factory pattern without invoking the setup (no running server needed). The setup functions are designed for use in vitest.config.ts, not direct invocation. |
| Pre-built Global Setups | This example demonstrates the pre-built global setup functions available for common client types and how to use them in Vitest configuration. It shows:
NOTE: This example documents usage patterns without invoking setups (no running server needed). The setup functions are designed for use in vitest.config.ts, not direct invocation. |
| Integration Example - Complete Test Setup | This example demonstrates how all testing package components work together for a real test scenario. It shows:
This example works with or without a running mock server, providing helpful guidance in either case. |
Quick Start
Section titled “Quick Start”Run any example from the repository’s examples directory:
cd examplesnpm run example testing/01-*.ts