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
.featurefiles 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:
.restlynrccentralizes 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@debugto 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.jsonfor 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
- Draft your feature file under
features/. - Configure defaults in
.restlynrc. -
Generate step maps and tests:
restlyn steps --all restlyn tests --all -
Run the generated tests and produce reports:
restlyn verify --report -
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
,,, andinside 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-erroronce your suite stabilizes. - Keep
restlyn mockrunning 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.