smol
A JavaScript test runner. Like Mocha but smol.
Ok so basically I'm very smol
Why smol
- No global variables
- No dependencies
- Basically it's very smol
Installation
npm add smoltest
Synopsis
smol <DIR>
Usage
Put the following code in a file:
const assert = strictconst describe it = exports
File: string.test.js
Run the tests:
npx smol .
Test files are those
- Starting with test and ending with .js
- Ending with .test.js
- Ending with .spec.js
Syntax
Smol supports the following Mocha syntax:
Mocha "BDD" 🔗 | Mocha "TDD" 🔗 |
---|---|
describe | suite |
it | test |
before | suiteSetup |
after | suiteTeardown |
beforeEach | setup |
afterEach | teardown |
context | |
specify | |
xdescribe | |
xit |
Unlike Mocha, these functions aren't global. They can be imported as follows:
const describe it beforeEach afterEach = exports
You can also write test functions without any special syntax whatsoever, similar to pytest. Make sure to export any functions that are meant to be test cases with names starting with test.
For example:
const assert = strict exports'test Array#concat()' = { assert} exports'test Array#fill()' = { assert}
File: array.test.js
License
MIT