Why I Built Restlyn

API testing still asks engineers to stitch together step definitions, assertion helpers, and reporting plugins. Restlyn tackles that overhead by translating Gherkin feature files into runnable Mocha suites automatically. It handles token flows, schema validation, retry logic, and reporting without forcing you to write glue code.

The codebase continues to live at amiya-pattnaik/restlyn, and the npm package ships under the same restlyn name, so you can jump in without tracking any rename notices.

Core Ideas

  • Feature-first authoring: Treat .feature files as the single source of truth for REST workflows and contract checks.
  • Zero step definitions: Restlyn ships opinionated step implementations so you can focus on the scenario, not on binding code.
  • Rich reports: HTML and PDF summaries help teams review results asynchronously, while JSON output supports CI gates.
  • Configurable by design: .restlynrc centralizes paths, base URLs, headers, and environment defaults.

Capabilities At A Glance

  • REST verbs: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
  • Token handling: extract values from responses, re-use them in later steps, and interpolate into request bodies.
  • Data-driven tests: feed CSV or JSON datasets directly into scenarios.
  • Retry and tagging: use @retry, @skip, @only, and @debug to control execution.
  • Contract checks: validate responses against JSON Schema files generated with restlyn schema.
  • Mock server: bootstrap local endpoints with restlyn mock.
  • Warning aggregation: collect missing schemas or data references into restlyn-warnings.json for CI visibility.

Install And Run

Global install (recommended for repeated use):

npm install -g restlyn
restlyn --help

Project scoped install:

npm install --save-dev restlyn
npx restlyn --version

Typical Workflow

  1. Draft your feature file under features/.
  2. Configure defaults in .restlynrc.
  3. Generate step maps and tests:

    restlyn steps --all
    restlyn tests --all
    
  4. Run the generated tests and produce reports:

    restlyn verify --report
    
  5. Need a schema? Capture it straight from a live response:

    restlyn schema --url /users/2 --method GET --output userProfile
    

Sample Feature And Generated Test

Feature Input

Feature: Users API

  Scenario: Get user by id
    Given base URL is "https://reqres.in/api"
    When I GET "/users/2"
    Then response status should be 200
    And response body should contain key "data"

Generated Step Map (excerpt)

{
  "feature": "Users",
  "scenarios": [
    {
      "name": "Get user by id",
      "baseUrl": "https://reqres.in/api",
      "requests": [{ "method": "GET", "endpoint": "/users/2" }],
      "assertions": [
        { "type": "status", "expected": 200 },
        { "type": "contains", "key": "data" }
      ]
    }
  ]
}

Generated Test Snippet

const { expect } = require('chai');
const { get, retryRequest } = require('restlyn/runtime/request');

describe('Users', () => {
  it('Get user by id', async () => {
    const baseUrl = 'https://reqres.in/api';
    const headers = { 'Content-Type': 'application/json' };
    const response = await retryRequest(() => get(`${baseUrl}/users/2`, { headers }));
    expect(response.status).to.equal(200);
    expect(response.data).to.have.property('data');
  });
});

Advanced Tips

  • Use dynamic tokens like ,, , and inside request tables for quick data variation.
  • Enable retries on unstable endpoints with @retry(3) directly in the scenario header.
  • Turn warnings into build failures with restlyn verify --warn-as-error once your suite stabilizes.
  • Keep restlyn mock running during local development to stub dependencies.

Join The Feedback Loop

Restlyn grows whenever teams share their API edge cases, schema patterns, or data generation needs. If something requires manual intervention in your workflow, open an issue or start a discussion. The roadmap includes broader gRPC coverage, richer contract diffing, and exportable analytics once we gather the right use cases.