包详细信息

@japa/expect-type

japa9.4kMIT2.0.3

Write assertions for TypeScript types

自述文件

@japa/expect-type

Write assertions for TypeScript types

[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] license-image

The expect-type plugin of Japa helps you write assertions against the TypeScript types. There is no runtime behavior with the expect-type plugin and you need to compile your code to view the assertion errors.

The plugins wraps expect-type under the hood.

Complete API documentation

Installation

Install the package from the npm registry as follows:

npm i @japa/expect-type
yarn add @japa/expect-type

Usage

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

import { expectTypeOf } from '@japa/expect-type'
import { configure } from '@japa/runner'

configure({
  plugins: [expectTypeOf()],
})

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

test('test title', ({ expectTypeOf }) => {
  expectTypeOf({ foo: 'bar' }).toEqualTypeOf<{ foo: string }>()
})

[gh-workflow-url]: https://github.com/japa/expect-type/actions/workflows/checks.yml 'Github action'

[npm-url]: https://www.npmjs.com/package/@japa/expect-type/v/latest 'npm'