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

  1. Go to repository Settings → Secrets and variables → Actions
  2. Click "New repository secret"
  3. Add MOCK_API_URL with your project URL
  4. Add MOCK_API_TOKEN if using authentication

GitLab CI/CD Variables

  1. Go to Settings → CI/CD → Variables
  2. Click "Add variable"
  3. Set key as API_URL, value as your mock API URL
  4. Check "Protect variable" and "Mask variable" for security

Jenkins Credentials

  1. Go to Manage Jenkins → Credentials
  2. Add new credentials (Secret text)
  3. Use ID like mock-api-url
  4. 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