ReScript bindings for mocha
npm install @dsiu/rescript-mochaReScript bindings for Mocha testing framework. Updated for ReScript v12.
``bash`
npm install @dsiu/rescript-mocha mocha --save-dev
Add to rescript.json:
`json`
{
"bs-dependencies": [
"@dsiu/rescript-mocha"
]
}
`rescript
open RescriptMocha.Mocha
module Assert = RescriptMocha.Assert
describe("Array.map", () => {
it("should map the values", () =>
Assert.deepEqual(Array.map([1, 2, 3], i => i * 2), [2, 4, 6])
)
it("should work with an empty array", () =>
Assert.deepEqual(Array.map([], i => i * 2), [])
)
})
`
`rescript
open RescriptMocha.Promise_
describe("Async tests", () => {
it("should resolve after delay", () => {
Promise.make((resolve, _reject) => {
setTimeout(() => resolve(42), 100)->ignore
})->Promise.then(value => {
Assert.equal(value, 42)
Promise.resolve()
})
})
})
`
`rescript
open RescriptMocha.Async
describe("Callback tests", () => {
it("should call done when complete", done => {
setTimeout(() => done(), 100)->ignore
})
})
`
- Mocha - Synchronous describe, it, before, after, beforeEach, afterEachPromise_
- - Promise-based async versionsAsync
- - Callback-based async versions (done-style)Assert
- - Node.js assert module bindings
Each module also provides _only and _skip variants (e.g., it_only, describe_skip).
``
All code is licensed as MIT. See LICENSE.
This project is a fork of rescript-mocha by TheSpyder, which in turn was forked from bs-mocha after it was abandoned.