Small and fast Typescript unit testing library with no dependencies.
yarn add briefest --dev
npm install briefest --save-dev
UMD file is also available on unpkg:
<script src="https://unpkg.com/browse/briefest/testing.min.js"></script>
You can use the library via window.briefest
.
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()
})
import { test } from "briefest"
const callbackTest = (func: (n: number) => void) => setTimeout(() => func(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()
})
})
Feel free to send some pull request or issue.
MIT license
© 2020 Jose Quintana