JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3481
  • Score
    100M100P100Q124310F
  • License MIT

Assertion package built on top of Jest expect

Package Exports

  • @japa/expect

Readme

@japa/expect

Assertion library built on top of jest-expect

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

An assertion library built on top of jest-expect.

Installation

Install the package from the npm registry as follows:

npm i @japa/expect

yarn add @japa/expect

Usage

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

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

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

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

test('test title', ({ expect }) => {
  expect(100).toBeWithinRange(90, 110)
})

TypeScript types

TypeScript will not provide intellisense for the expect property, since it is added at runtime.

However, you can define the static type using the TypeScript module augmentation. Create a new file japa-types.ts and write the following code inside it.

import { Expect } from '@japa/expect'

declare module '@japa/runner' {
  interface TestContext {
    expect: Expect
  }
}