API client to test endpoints over HTTP. Uses superagent under the hood
The API client plugin of Japa makes it super simple to test your API endpoints over HTTP. You can use it to test any HTTP endpoint that returns JSON, XML, HTML, or even plain text.
It has out of the box support for:
application/json
, application/x-www-form-urlencoded
and multipart
.Install the package from the npm registry as follows:
npm i @japa/api-client
yarn add @japa/api-client
You can use the assertion package with the @japa/runner
as follows.
import { apiClient } from '@japa/api-client'
import { configure } from '@japa/runner'
configure({
plugins: [apiClient({ baseURL: 'http://localhost:3333' })]
})
Once done, you will be able to access the client
property from the test context.
test('test title', ({ client }) => {
const response = await client.get('/')
})
Table of contents