2.0.3 • Published 1 month ago

@japa/api-client v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@japa/client

API client to test endpoints over HTTP. Uses superagent under the hood

github-actions-image npm-image license-image typescript-image

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:

  • Multiple content types including application/json, application/x-www-form-urlencoded and multipart.
  • Ability to upload files.
  • Read and write cookies with the option to register custom cookies serializer.
  • Lifecycle hooks. A great use-case of hooks is to persist and load session data during a request.
  • All other common abilities like sending headers, query-string, and following redirects.
  • Support for registering custom body serializers and parsers.

Complete API documentation

Installation

Install the package from the npm registry as follows:

npm i @japa/api-client

yarn add @japa/api-client

Usage

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('/')
})
2.0.3

1 month ago

2.0.2

5 months ago

2.0.0-1

8 months ago

2.0.0-0

10 months ago

2.0.1

6 months ago

2.0.0

7 months ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago