README
MiniSpec
MiniSpec is a minimalist test/spec execution engine for TypeScript and JavaScript, inspired by RSpec and minitest.
It works out-of-the-box with CommonJS, ESM and TypeScript.
Its purpose is to remain minimalistic, without any runtime dependency and really low number of development dependencies.
Example
Add MiniSpec to your dev dependencies:
$ npm install --save-dev minispec
Consider the following TypeScript file:
// spec/minispec_entrypoint.ts
import assert from 'assert/strict'
import MiniSpec, { describe, it, beforeEach } from 'minispec'
describe('MiniSpec test engine', async () => {
let worksWell: boolean
beforeEach(async () => {
worksWell = true
})
it('works well', async () => {
assert.ok(worksWell)
})
})
MiniSpec.execute()
Or the following JavaScript file using ESM:
// spec/minispec_entrypoint.js
import assert from 'assert/strict'
import MiniSpec, { describe, it, beforeEach } from 'minispec'
describe('MiniSpec test engine', async () => {
let worksWell
beforeEach(async () => {
worksWell = true
})
it('works well', async () => {
assert.ok(worksWell)
})
})
MiniSpec.execute()
When you execute the TypeScript file:
$ npx ts-node spec/minispec_entrypoint.ts
or the JavaScript file:
$ node spec/minispec_entrypoint.js
It will output the following:
MiniSpec test engine
works well
Finished in 1 milliseconds (discovering took 0 milliseconds, execution took 1 milliseconds)
1 test, no failure 👏
Note: depending your TypeScript and ts-node configuration, you may need to use the specific ts-node esm loader if your package is a module.
Documentation and examples
The documentation is available in the wiki of the project.
Some examples are available in the repository.