DEV Community

Alex Spinov
Alex Spinov

Posted on

Step CI Has a Free API Testing Framework That Replaces Postman Collections

Step CI is the open-source API testing and monitoring framework. Define tests in YAML, run them in CI/CD, catch breaking changes before they hit production.

What Is Step CI?

Step CI is like Postman Collections + automated testing, but as code. Write API tests, run them locally or in CI, get reports.

Quick Start

npm install -g stepci
Enter fullscreen mode Exit fullscreen mode

Define Tests

# workflow.yml
version: "1.1"
name: API Tests
env:
  host: https://api.example.com
  token: ${{ env.API_TOKEN }}

tests:
  health:
    steps:
      - name: Health check
        http:
          url: ${{ env.host }}/health
          method: GET
          check:
            status: 200
            json:
              status: ok

  users:
    steps:
      - name: Create user
        http:
          url: ${{ env.host }}/api/users
          method: POST
          headers:
            Authorization: Bearer ${{ env.token }}
          json:
            name: Test User
            email: test@example.com
          check:
            status: 201
            json:
              name: Test User
          captures:
            userId:
              json: $.id

      - name: Get user
        http:
          url: ${{ env.host }}/api/users/${{ captures.userId }}
          method: GET
          headers:
            Authorization: Bearer ${{ env.token }}
          check:
            status: 200
            json:
              id: ${{ captures.userId }}
              name: Test User

      - name: Delete user
        http:
          url: ${{ env.host }}/api/users/${{ captures.userId }}
          method: DELETE
          headers:
            Authorization: Bearer ${{ env.token }}
          check:
            status: 204
Enter fullscreen mode Exit fullscreen mode

Run Tests

# Run locally
stepci run workflow.yml

# With environment variables
API_TOKEN=your-token stepci run workflow.yml

# Verbose output
stepci run workflow.yml --verbose
Enter fullscreen mode Exit fullscreen mode

Advanced Features

Load Testing

tests:
  load-test:
    steps:
      - name: Stress test
        http:
          url: ${{ env.host }}/api/data
          method: GET
        options:
          loadTest:
            phases:
              - duration: 30
                arrivalRate: 10
              - duration: 30
                arrivalRate: 50
Enter fullscreen mode Exit fullscreen mode

JSON Schema Validation

steps:
  - name: Validate response schema
    http:
      url: ${{ env.host }}/api/products
      method: GET
      check:
        status: 200
        jsonSchema:
          type: array
          items:
            type: object
            required: [id, name, price]
            properties:
              id: { type: integer }
              name: { type: string }
              price: { type: number, minimum: 0 }
Enter fullscreen mode Exit fullscreen mode

GraphQL Testing

steps:
  - name: GraphQL query
    http:
      url: ${{ env.host }}/graphql
      method: POST
      graphql:
        query: |
          query GetUser($id: ID!) {
            user(id: $id) { name email }
          }
        variables:
          id: "123"
      check:
        status: 200
        json:
          data.user.name: Alice
Enter fullscreen mode Exit fullscreen mode

GitHub Actions

- name: Run API tests
  uses: stepci/stepci@v1
  with:
    workflow: workflow.yml
  env:
    API_TOKEN: ${{ secrets.API_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

Step CI vs Alternatives

Feature Step CI Postman k6
Open source Yes No Yes
Tests as code YAML GUI + JSON JS
CI/CD native Yes Newman Yes
Load testing Yes Limited Advanced
API monitoring Yes Paid No
Schema validation Yes Yes Manual

Testing scraping APIs? Scrapfly provides reliable web data APIs. Email spinov001@gmail.com for API testing + scraping setups.

Top comments (0)