2.1.17 • Published 3 years ago
testapi2 v2.1.17
testapi2
Quick unit test and export document APIs
Features
- Test APIs base on scenario files
- Validate response data, response headers...
- Re-use variable after each steps
- Split a big testcases to many smaller testcases which make easy testing for large project
- Easy to extends for specific project
How to use
Installation
// install via npm
npm install -g testapi2
// install via yarn
yarn global add testapi2 --prefix /usr/local
Write testcase
- Main scenario file name is
index.testapi2.yaml
Run test
testapi2 \"$PWD/$PATH_OF_SCENARIO_FILE/index.testapi2.yaml\"
Scenario
title: # Document title
description: # Document description
info:
contact:
email: email@gmail.com # Author
version: 1.0.0 # Document version
endpoints: # Example server in document
production: https://api.abc.vn/edge-main/v1.0
staging: https://staging-api.abc.vn/edge-main/v1.0
development: http://localhost:3001
# debug: true
docs: # Config document
headers: [] # Doc request headers
responseHeaders: ["content-type"] # Doc response headers
output: # Output document
- !output-swagger # Config for swagger document
saveTo: ../DOC/api.doc.yaml # Output path
raw: # Ref to swagger tags
- !output-md # Config for markdown document
saveTo: ../DOC/api.doc.md
vars: # Declare global variables
url: http://0.0.0.0:3001
templates: # Declare templates which not run
# Make request
- !api
- !get
- !post
- !put
- !patch
- !delete
- !head
- !group
steps:
# Make request
- !api # REST API
- !get # API GET method
- !delete # API DELETE method
- !head # API HEAD method
- !post # API POST method
- !put # API PUT method
- !patch # API PATCH method
- !upload # Upload file in body request
- !validate # Validate logic
# Print
- !echo # Print data
- !echo-schema # Print object schema
# Logic
- !script # Inject javascript in scenario
- !vars # Declare variables
# Validate
- !validate # Validate logic
- !status # Validate response status code
- !status-text # Validate response status text
# Common
- !pause # Pause or delay calls
- !file # Import files
- !group # Group steps
- !exec # Execute external command
- !input # Get user input keyboard
- !output-file # Save data to file
- !output-swagger # Generate & save document to swagger file
- !output-md # Generate & save document to markdown file
All of tags
# Make request
- !api # REST API
- !get # API GET method
- !delete # API DELETE method
- !head # API HEAD method
- !post # API POST method
- !put # API PUT method
- !patch # API PATCH method
- !upload # Upload file in body request
- !validate # Validate logic
# Print
- !echo # Print data
- !echo-schema # Print object schema
- !output-file # Save data to file
# Logic
- !script # Inject javascript in scenario
- !vars # Declare variables
# Validate
- !validate # Validate logic
- !status # Validate response status code
- !status-text # Validate response status text
# Common
- !pause # Pause or delay calls
- !file # Import files
- !group # Group steps
- !exec # Execute external command
- !input # Get user input keyboard
# Document
- !doc-swagger # Generate document to swagger file
- !doc-md # Generate document to markdown file
Scenario schema
Example
2.1.17
3 years ago
2.1.16
3 years ago
2.1.15
3 years ago
2.1.14
3 years ago
2.1.13
3 years ago
2.1.12
3 years ago
2.1.10
4 years ago
2.1.11
4 years ago
2.1.8
4 years ago
2.1.9
4 years ago
2.1.7
4 years ago
2.1.6
4 years ago
2.1.5
4 years ago
2.1.4
4 years ago
2.1.3
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.19
4 years ago
2.0.17
4 years ago
2.0.18
4 years ago
2.0.15
4 years ago
2.0.16
4 years ago
2.0.14
4 years ago
2.0.13
4 years ago
2.0.12
4 years ago
2.0.11
4 years ago
2.0.10
4 years ago
2.0.9
4 years ago
2.0.8
4 years ago
2.0.5
4 years ago
2.0.7
4 years ago
2.0.6
4 years ago
2.0.3
4 years ago
2.0.4
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago