Tests are inevitable to continuous integration and continuous delivery. Writing tests in ESM JavaScript with top-level async/await can be tricky. Especially in the case where we might want to maintain a sequence of tests. The implementation is more of a concept, than an attempt replace mocha
or jest
or AVA
.
A simple test suite:
const $ = new Suite('Math')
$.it('adds', _ => expect(2+1).equals(3))
await $.it('adds async', async _ => {
const req = await fetch('http://api.mathjs.org/v4/?expr=1%2B2')
const result = await result.text()
expect(result).equals('3')
})
$.done()
- Simplicity
- Works for pure ESM TypeScript
- Batteries included i.e.
expect
is provided with plugins:- chai-http
- chai-array
- chai-sorted, etc