Repository
Current version released
2 years ago
Dependencies
std
Versions
Deno-API-Test
LICENSE
This software is released under the MIT License, see LICENSE.
Overview
This package make REST API Tests easy.
Usage
import package
import { Method, ApiTest } from "https://deno.land/x/apitest@0.1.3/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"
})
})
Deno.test("Receive Object Test", async () => {
await api.assert({
path: '/object',
expected: { name: "hello", age: 10 }
})
})
Deno.test("Receive Array Test", async () => {
await api.assert({
path: '/array',
expected: [
{ name: 'hello', age: 10 },
{ name: 'world', age: 9 },
]
})
})
Execute
in terminal
deno test --allow-net
What this package can’t do
This package cannot be considered a success with any response