npm.io
0.0.1-beta.1 • Published 6 years ago

briefest

Licence
MIT
Version
0.0.1-beta.1
Deps
0
Size
17 kB
Vulns
0
Weekly
0

Briefest npm npm Build Status js-standard-style

Small and fast Typescript unit testing library with no dependencies.

Testing using Briefest

Install

Yarn

yarn add briefest --dev

NPM

npm install briefest --save-dev

UMD file is also available on unpkg:

<script src="https://unpkg.com/briefest/briefest.umd.min.js"></script>

You can use the library via window.briefest.

Usage

Simple tests
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
import { test } from "briefest"

const callbackTest = (cb: (v: number) => void) => setTimeout(() => cb(500), 200)
const asyncTest = () => new Promise<number>((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 or issue.

License

MIT license

2020 Jose Quintana

Keywords