DEV Community

ProRecruit
ProRecruit

Posted on

How I Set Up a Complete API Testing Environment in 20 Minutes for Free

There's a tax on API development that nobody warns you about: the time you spend setting up test infrastructure before you can actually test anything.

Database seeds. Docker compose files. Auth tokens. Postman collections. Environment variables. For a small project, this can take half a day. For a new team member onboarding, it can take a full day.

I found a faster path.

Step 1: OpenAPI spec as the foundation (5 minutes)

If you're building a REST API, write the spec first. Not the full spec — just the routes you're building this sprint. OpenAPI YAML is readable and writable without tooling:

paths:
  /users:
    get:
      summary: List users
      responses:
        '200':
          description: User list
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/User'
Enter fullscreen mode Exit fullscreen mode

This spec is your contract. Everything else derives from it.

Step 2: Import to a mock server (2 minutes)

Import the spec into moqapi.dev. Every route in the spec is now a live endpoint. Call it from any HTTP client — curl, Postman, your frontend code, your test suite.

Step 3: AI-generate realistic test data (3 minutes)

The mock returns schema-accurate data by default. To make it more realistic, use the "Generate with AI" button. It fills each resource with contextually appropriate values — not user_1234 strings, but actual name/email/date patterns that match your field names.

Step 4: Connect your frontend (2 minutes)
NEXT_PUBLIC_API_URL=https://moqapi.dev/api/invoke/mock/<id>

Done. Your frontend is connected to a live API that returns realistic data.

Step 5: Set up chaos testing (3 minutes)

Enable 15% error injection. Use the UI. Fix blank screens. Fix missing loading states. Your feature is resilient before it ships.

Step 6: Share with the team (immediately)

The mock URL is public. Share it with frontend engineers, QA, designers, stakeholders doing UAT. Everyone works against the same mock. No local setup. No "it doesn't work on my machine."

Total time: 15–20 minutes. Total infrastructure

Top comments (0)