3.0.0 • Published 1 month ago

@japa/assert v3.0.0

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

@japa/assert

Assertion library built on top of Chai.assert

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

An assertion library built on top of Chai.assert with small tweaks and additional features like assertion planning.

Complete API documentation

Installation

Install the package from the npm registry as follows:

npm i @japa/assert

yarn add @japa/assert

Usage

You can use the assertion package with the @japa/runner as follows.

import { assert } from '@japa/assert'
import { configure } from '@japa/runner'

configure({
  plugins: [assert()]
})

Once done, you will be able to access the assert property on the test context.

test('test title', ({ assert }) => {
  assert.deepEqual({ id: 1 }, { id: 1})
})

Register open API schemas

You can register open API schema and then assert HTTP responses against.

configure({
  plugins: [assert({
    openApi: {
      schemas: [new URL('../api-spec.json', import.meta.url)]
    }
  })]
})

Validate response as follows.

test('get users', ({ assert }) => {
  const response = await supertest(baseUrl).get('/users')
  assert.isValidApiResponse(response)
})
3.0.0

1 month ago

2.1.0

5 months ago

2.0.0-2

8 months ago

2.0.1

6 months ago

2.0.0

7 months ago

2.0.0-1

10 months ago

2.0.0-0

10 months ago

1.3.7

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.2.4

2 years ago

1.3.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago