CLI-based API testing tool using YAML syntax
Write tests declaratively in YAML, run them with confidence. No boilerplate. No hassle.
npm install -g testlynCreate a tests.yaml file:
tests:
- name: Check API Health
url: https://api.example.com/health
method: GET
expect:
status: 200
- name: Create Resource
url: https://api.example.com/resources
method: POST
headers:
Content-Type: application/json
body:
name: "New Resource"
expect:
status: 201Run your tests:
testlyn run tests.yamlnpm install -g testlynnpm install --save-dev testlynThen in your package.json:
{
"scripts": {
"test:api": "testlyn run tests.yaml"
}
}testlyn run <file.yaml>-v, --verbose— Show detailed output for each test-s, --stop-on-error— Stop running tests on first failure
# Run with verbose output
testlyn run tests.yaml --verbose
# Stop on first error
testlyn run tests.yaml --stop-on-error
# Validate YAML syntax without running
testlyn validate tests.yaml
# Initialize a new test project
testlyn init my-api-teststests:
- name: Test Name
url: https://api.example.com/endpoint
method: GET
expect:
status: 200# Test suite name (optional)
suite: User API Tests
# Base URL (optional, can be used in all tests)
baseUrl: https://api.example.com
tests:
- name: List Users
url: /users
method: GET
headers:
Authorization: Bearer YOUR_TOKEN
expect:
status: 200
- name: Create User
url: /users
method: POST
headers:
Content-Type: application/json
Authorization: Bearer YOUR_TOKEN
body:
email: user@example.com
name: John Doe
expect:
status: 201
body:
id: 1
email: user@example.com
- name: Delete User
url: /users/1
method: DELETE
expect:
status: 204| Property | Required | Description |
|---|---|---|
name |
✅ | Test name/description |
url |
✅ | Full URL or path (if baseUrl is set) |
method |
❌ | HTTP method: GET, POST, PUT, DELETE, PATCH (default: GET) |
headers |
❌ | HTTP headers as key-value pairs |
body |
❌ | Request body (JSON object or string) |
expect |
✅ | Expected response conditions |
expect:
status: 200 # Expected HTTP status code
body: # Expected response body (partial match)
key: value- ✅ Declarative Tests — Write tests in simple YAML
- ✅ No Code Required — No JavaScript knowledge needed
- ✅ Fast & Lightweight — Minimal dependencies
- ✅ Clear Output — Color-coded test results
- ✅ Easy CI/CD Integration — Perfect for GitHub Actions, GitLab CI, etc.
- ✅ Status Code Assertions — Verify HTTP responses
- ✅ Body Assertions — Check response content
- ✅ Custom Headers — Support for authentication, custom headers
- Continuous Integration — Validate APIs in your CI/CD pipeline
- Contract Testing — Verify API contracts between services
- Smoke Testing — Quick health checks for production APIs
- Development — Test your API while building
- Documentation — Keep tests as living API documentation
name: API Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install -g testlyn
- run: testlyn run tests.yamlapi_tests:
image: node:18
script:
- npm install -g testlyn
- testlyn run tests.yamlmy-api-tests/
├── tests.yaml # Your test file
├── package.json
└── README.md
tests:
- name: Get User Profile
url: https://jsonplaceholder.typicode.com/users/1
method: GET
expect:
status: 200
body:
id: 1
- name: Create Post
url: https://jsonplaceholder.typicode.com/posts
method: POST
headers:
Content-Type: application/json
body:
userId: 1
title: Test Post
body: This is a test
expect:
status: 201tests:
- name: Login
url: https://api.example.com/auth/login
method: POST
headers:
Content-Type: application/json
body:
username: user@example.com
password: secret123
expect:
status: 200
body:
token: jwt_token
- name: Protected Endpoint
url: https://api.example.com/profile
method: GET
headers:
Authorization: Bearer jwt_token
expect:
status: 200- Environment variables support (
.envfiles) - Test dependencies (run tests in order, share data)
- Response assertions (JSON path, regex matching)
- Performance testing (response time assertions)
- HTML report generation
- Multi-format support (OpenAPI, Postman)
- Retry logic for flaky tests
- Parallel test execution
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT © 2024
Built with ❤️ in Abidjan