0.2.1 • Published 10 months ago

api-tuner v0.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

🎛️ API Tun3r 🎛️

API Tests Using n3 Rules

Prerequisites

Follow platform-specific instructions to install locally oor in a docker image.

To run api-tuner in GitHub workflow, you add this action to your jobs:

- uses: fabasoad/setup-prolog-action@v1

Installation

npm i api-tuner

Usage

> api-tuner --help
Usage: api-tuner [options] <path>...

Options:
  --silent           Less output
  --debug            Enable debug output
  --raw              Output raw results from eye
  --base-iri <iri>   Specify the base IRI for parsing the test case files
  --version          Show version information
  --help             Show this help message

Example

Create a test case file test.n3:

# test.n3
PREFIX : <http://example.com/>
PREFIX earl: <http://www.w3.org/ns/earl#>
PREFIX tuner: <https://api-tuner.described.at/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX string: <http://www.w3.org/2000/10/swap/string#>

<#getExampleDotCom>
  a earl:TestCase ;
  rdfs:label "Simple GET test" ;
.

# Configure a request
_:req
  a tuner:Request ;
  tuner:url <http://localhost:1080/example.com> ;
  tuner:method "GET" ;
.

{
  # Execute the request and capture its response
  _:req tuner:response ?res .

  # Check the response status code and content type
  ?res tuner:http_code 200 ;
    tuner:header ( "content-type" "text/html" ) ;
  .

  # Check the body contains the work "Example"
  ?res!tuner:body string:contains "Example Domain" .
} => {
  # Use te EARL vocabulary to assert the test passed
  <#getExampleDotCom> earl:outcome earl:passed .
} .

Execute the test case:

api-tuner test.n3

More examples

TBD

0.2.1

10 months ago

0.2.0

10 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago