briefest
v0.0.1-beta.1
Published
Small and fast Typescript unit testing library with no dependencies
Downloads
3
Maintainers
Readme
Briefest
Small and fast Typescript unit testing library with no dependencies.
Install
yarn add briefest --dev
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