Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@japa/expect

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@japa/expect

Assertion package built on top of Jest expect

Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
6.6K
-10.12%
Maintainers
1
Weekly downloads
 
Created
Source

@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
  }
}

Keywords

expect

FAQs

Package last updated on 11 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts