Using Vaktum
Local Development
Using Vaktum for Local Development
Vaktum provides powerful tools for testing and validating APIs during local development, helping you catch issues early before they reach production.
Benefits for Local Development
- Early Issue Detection: Identify and fix API problems during development
- Fast Feedback Loop: Quickly validate changes to your API
- Consistency: Ensure local API behavior matches specifications
- Documentation: Generate accurate documentation based on your implementation
Setting Up Vaktum for Local Development
Installing the Vaktum CLI
- Download the Vaktum CLI appropriate for your platform at Vaktum.com
- Verify the installation
./vaktum --version
- Add Vaktum to your PATH for easier access (optional)
- Save this as
local-env.json
in your project directory
Typical Local Development Workflow
- Start Your API Server
# Example: Start a Node.js API server npm run start:dev
- Validate Your API Definition
vaktum validate --api path/to/openapi.json
- Run Tests Against Local API
vaktum test --tests path/to/tests.json --env local-env.json
- Review Results and Fix Issues The CLI will provide detailed output about any test failures or validation issues
Integrating with Local Development Tools
Pre-commit Hooks
Set up Git pre-commit hooks to validate your API before committing changes:
#!/bin/sh
# .git/hooks/pre-commit
# Validate OpenAPI definition
vaktum validate --api path/to/openapi.json
# Exit with error code if validation fails
if [ $? -ne 0 ]; then
echo "API validation failed. Please fix the issues before committing."
exit 1
fi
Testing Local APIs Behind Firewalls
When your local API can't be accessed by Vaktum's cloud services:
- Use the Local Test Runner
vaktum runner start
- Configure Vaktum.com to use your local runner
- Go to the Runners section on Vaktum.com
- Verify your local runner is connected
- Select your local runner when executing tests
Local Development Environments
Configure multiple local environments for different scenarios:
- Mock Services: Test against mock services for faster feedback
- Local Database: Connect to a local database for full integration testing
- Feature Branches: Create specific environments for feature branches
Best Practices for Local Development
- Version Control: Keep your API definition and tests in version control
- Consistent Environments: Keep local and CI environments as similar as possible
- Automated Testing: Run tests automatically during development
- Incremental Updates: Validate changes incrementally as you develop
- Mock Dependencies: Use mock services for external dependencies
Troubleshooting Local Testing
Common issues and solutions:
- Connection Refused: Ensure your local API server is running and accessible
- CORS Issues: Configure your local server to allow Vaktum test requests
- Port Conflicts: Check for port conflicts with other local services
- Network Configuration: Verify firewall and network settings
For more advanced CI/CD integration, see the CI/CD section.