@runtyping/test-type-writers
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

@runtyping/test-type-writers

A testing library for runtyping typewriters.

Usage

testTypeWriters<MyBaseValidatorType>({
  createNumberValidator: () => NumberValidator,
  createStringValidator: () => StringValidator,
  createObjectValidator: (shape) => ObjectValidator(shape),
  typeWriters: new MyTypeWriters(),
  validate(validator, data) {
    // should throw an error if it fails
    validator.validate(data)
  },

  // optional, ignore certain tests if they can't be achieved
  // by the validator
  ignore: ['variadicTuples.B'],
})

Adding a test

  1. Create a source fixture in fixtures/source. This will represent a source files containing static types we wish to build validators against.
  2. Create a data fixture in fixtures/data, with the same name you gave the source file. It should contain an array of success and failure data inputs for each type exported from the source file.

See fixtures/source/array.ts & fixtures/data/array.ts as an example.

Readme

Keywords

none

Package Sidebar

Install

npm i @runtyping/test-type-writers

Weekly Downloads

1

Version

3.1.0

License

MIT

Unpacked Size

56.9 kB

Total Files

98

Last publish

Collaborators

  • johngeorgewright