Skip to main content

Deno-API-Test

LICENSE

This software is released under the MIT License, see LICENSE.

Overview

This package make REST API Tests easy.

Usage

example code

import package

import { Method, ApiTest } from "https://deno.land/x/apitest@0.1.0/mod.ts"

new Instance by base URL

const api = new ApiTest('https://xxxx.com')

Test Server

To “baseURL + path” with method and parameter

Deno.test("Send Object Test", async () => {
    await api.assert({
        path: '/object',
        method: Method.PATCH,
        parameter: { first: "Tom", last: "Riddle" },
    })
})

Assert

assertEquals, by expected status (default 200) and expected body (default empty)

Deno.test("Not Found Test", async () => {
    await api.assert({
        path: '/not',
        expectedHTTPStatus: 404,
        expected: "Not Found"
    })
})

Execute

in terminal

deno test --allow-net

What this package can’t do

This package cannot be considered a success with any response