Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mvasilkov/smol
A JavaScript test runner. Like Mocha but smol.
https://github.com/mvasilkov/smol
javascript mocha no-dependencies smol test
Last synced: 29 days ago
JSON representation
A JavaScript test runner. Like Mocha but smol.
- Host: GitHub
- URL: https://github.com/mvasilkov/smol
- Owner: mvasilkov
- License: mit
- Created: 2020-01-17T17:47:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T18:09:32.000Z (over 4 years ago)
- Last Synced: 2024-10-05T17:01:27.977Z (about 1 month ago)
- Topics: javascript, mocha, no-dependencies, smol, test
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/smoltest
- Size: 18.6 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
smol
===A JavaScript test runner. Like Mocha but smol.
[][github]
*Ok so basically I'm very smol*
[![npm][npm-badge]][npm-url]
[![no dependencies][dependencies-badge]][dependencies-url]---
Why smol
---- No global variables
- No dependencies
- Basically it's very smolInstallation
---```sh
npm add smoltest
```Synopsis
---```sh
smol
```Usage
---Put the following code in a file:
```javascript
const assert = require('assert').strict
const { describe, it } = require('smoltest')(exports)describe('String', () => {
it('#concat()', () => {
assert.strictEqual('a'.concat('b'), 'ab')
})it('#repeat()', () => {
assert.strictEqual('a'.repeat(2), 'aa')
})
})
```File: string.test.js
Run the tests:
```sh
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" [🔗][docs-bdd] | Mocha "TDD" [🔗][docs-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:```javascript
const { describe, it, beforeEach, afterEach } = require('smoltest')(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:
```javascript
const assert = require('assert').strictexports['test Array#concat()'] = () => {
assert.deepStrictEqual(['a'].concat(['b']), ['a', 'b'])
}exports['test Array#fill()'] = () => {
assert.deepStrictEqual(Array(2).fill('a'), ['a', 'a'])
}
```File: array.test.js
License
---MIT
[github]: https://github.com/mvasilkov/smol
[npm-badge]: https://img.shields.io/npm/v/smoltest.svg?style=flat
[npm-url]: https://www.npmjs.com/package/smoltest
[dependencies-badge]: https://img.shields.io/librariesio/release/npm/smoltest?style=flat
[dependencies-url]: https://www.npmjs.com/package/smoltest?activeTab=dependencies
[docs-bdd]: https://mochajs.org/#bdd
[docs-tdd]: https://mochajs.org/#tdd