An open API service indexing awesome lists of open source software.

https://github.com/joseluisq/briefest

Small and fast Typescript unit testing library with no dependencies. [WIP]
https://github.com/joseluisq/briefest

browser library nodejs testing typescript unit-testing

Last synced: about 1 year ago
JSON representation

Small and fast Typescript unit testing library with no dependencies. [WIP]

Awesome Lists containing this project

README

          

# Briefest [![npm](https://img.shields.io/npm/v/briefest.svg)](https://www.npmjs.com/package/briefest) [![npm](https://img.shields.io/npm/dt/briefest.svg)](https://www.npmjs.com/package/briefest) [![Build Status](https://travis-ci.com/joseluisq/briefest.svg?token=qB1iXZPP7iKjyeqfe4pA&branch=master)](https://travis-ci.com/joseluisq/briefest) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

> Small and fast [Typescript](https://www.typescriptlang.org/) [unit testing](https://en.wikipedia.org/wiki/Unit_testing) library with no dependencies.

![Testing using Briefest](https://user-images.githubusercontent.com/1700322/75325099-8215ad80-5878-11ea-9178-a62379ac92c5.png)

## Install

[Yarn](https://github.com/yarnpkg/)

```sh
yarn add briefest --dev
```

[NPM](https://www.npmjs.com/)

```sh
npm install briefest --save-dev
```

[UMD](https://github.com/umdjs/umd/) file is also available on [unpkg](https://unpkg.com):

```html

```

You can use the library via `window.briefest`.

## Usage

### Simple tests

```ts
import { test } from "briefest"

test("Simple tests", (t, done) => {
t.isPrimitive(-1)
t.isPrimitive(2n ** 8n)

t.isEqualPrimitive(undefined, undefined)

t.isEqual("", "")
t.isEqual(64n, 2n ** 6n)

t.isNotEqual({}, {})
t.isNotEqual(new Date(), new Date())

done()
})
```

### Asynchronous tests

```ts
import { test } from "briefest"

const callbackTest = (func: (n: number) => void) => setTimeout(() => func(500), 200)
const asyncTest = () => new Promise((resolve) => setTimeout(() => resolve(600), 100))

test("Async tests", (t, done) => {
callbackTest(async (val) => {
t.isEqual(500, val)

// an async/await example
t.isEqual(600, await asyncTest())

done()
})
})
```

## Contributions
Feel free to send some [pull request](https://github.com/joseluisq/briefest/pulls) or [issue](https://github.com/joseluisq/briefest/issues).

## License
MIT license

© 2020 [Jose Quintana](http://git.io/joseluisq)