1.0.5 • Published 4 years ago

smoltest v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

smol

A JavaScript test runner. Like Mocha but smol.

Ok so basically I'm very smol

npm no dependencies


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 = 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')
    })
})

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" 🔗
describesuite
ittest
beforesuiteSetup
aftersuiteTeardown
beforeEachsetup
afterEachteardown
context
specify
xdescribe
xit

Unlike Mocha, these functions aren't global. They can be imported as follows:

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:

const assert = require('assert').strict

exports['test Array#concat()'] = () => {
    assert.deepStrictEqual(['a'].concat(['b']), ['a', 'b'])
}

exports['test Array#fill()'] = () => {
    assert.deepStrictEqual(Array(2).fill('a'), ['a', 'a'])
}

License

MIT

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago