2.3.1 • Published 2 years ago

@hackbg/runspec v2.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@hackbg/runspec NPM version

Minimal test runner and reporter.

Its gimmick is that there are no gimmicks. No describe, no expect, no beforeEach/afterAll, etc. Who told you you needed those, anyway?

How to use

  1. Define your test cases as plain old functions - synchronous or asynchronous, it's smart enough to handle both correctly, and you're smart enough to use JavaScript's standard control flow vocabulary.

  2. Group test cases into specifications via regular ES modules (i.e. collect them all in an object and export default it.)

// spec1.spec.js
export default {
  'synchronous test' (assert) {
    assert(true)
  },
  async 'asynchronous test' (assert) {
    await someAsyncFunction()
    assert(true)
  }
}
  1. Group specifications into a test suite in a single executable script which calls runSpec on the test suite to execute the specifications. By default, it looks at process.argv.slice(2) - if it's empty, it runs all specs. If it contains names of test suites, it runs only those.
// index.spec.js
import runSpec from '@hackbg/runspec'
import Spec1   from './spec1.spec'
import Spec2   from './spec2.spec'
import Spec3   from './spec3.spec'
runSpec({ Spec1, Spec2, Spec3 })
node index.spec.js
node index.spec.js Spec1
node index.spec.js Spec2 Spec3
  1. Add the script to your project's package.json and run with npm test.
{
  "scripts": {
    "test": "node index.spec.js"
  }
}
npm test
npm test Spec1
npm test Spec2 Spec3
2.3.0

2 years ago

2.3.1

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago