Integration
CI/CD Integration
Use mock APIs in your continuous integration and deployment pipelines
CI/CD with Mock APIs
Integrate Mock API Builder into your CI/CD pipeline to run automated tests, validate integrations, and ensure your application works correctly before deploying to production.
Automated Testing
Run integration tests against mock APIs in every build
Fast Feedback
Get quick test results without waiting for real APIs
Consistent Data
Use predictable mock data across all test runs
GitHub Actions
Basic Workflow with Mock API
Create a .github/workflows/test.yml file in your repository:
plaintext
Advanced Workflow with Multiple Environments
plaintext
GitLab CI/CD
GitLab Pipeline Configuration
Create a .gitlab-ci.yml file:
plaintext
Jenkins
Jenkinsfile Configuration
Create a Jenkinsfile in your repository:
plaintext
CircleCI
CircleCI Configuration
Create a .circleci/config.yml file:
plaintext
Managing Environment Variables
Setting Up Mock API URLs
GitHub Actions Secrets
- Go to repository Settings → Secrets and variables → Actions
- Click "New repository secret"
- Add
MOCK_API_URLwith your project URL - Add
MOCK_API_TOKENif using authentication
GitLab CI/CD Variables
- Go to Settings → CI/CD → Variables
- Click "Add variable"
- Set key as
API_URL, value as your mock API URL - Check "Protect variable" and "Mask variable" for security
Jenkins Credentials
- Go to Manage Jenkins → Credentials
- Add new credentials (Secret text)
- Use ID like
mock-api-url - Reference in Jenkinsfile with
credentials('mock-api-url')
Environment-Specific Configuration
Use different mock APIs for different environments:
javascript
Testing Strategies
Unit Tests with Mock APIs
javascript
Integration Tests
javascript
E2E Tests with Playwright/Cypress
javascript
Best Practices
- ✓Use environment variables for API URLs—never hardcode them in tests
- ✓Create dedicated mock projects for CI/CD to avoid conflicts with development
- ✓Run tests in parallel when possible to speed up builds
- ✓Cache dependencies (node_modules) to reduce build times
- ✓Fail fast run quick tests (unit) before slow tests (E2E)
- ✓Store test results as artifacts for debugging failed builds
- ✓Use matrix builds to test against multiple Node.js versions
- ✓Monitor CI/CD performance and optimize slow steps