mocha-exports-ui
This projects lets you write your Mocha tests in the same way as original exports UI but it adds pending and exclusive tests plus shortcuts like let
and const
for assigning variables to the context.
Compare BDD interface and mocha-exports-ui interface:
// mocha-exports-ui interface:moduleexports = 'User': // will add variables to the context but only once (similar to `beforeAll`) const: { ; } { return thisdb; } // same as `const` but runs before each test like `beforeEach` let: { name: 'joe' password: 'qwerty' email: 'joe@gmail.com'; } // a test suite is just an object that can contain other test suites and tests '.signup': // a test { name: 'another_joe' password: 'qwerty' email: 'joe@gmail.com'; } '#save': // adding minus sign will skip the test, this is the same as calling `it.skip` {} {} // exclamation point makes a test or a suite exclusive, it is equivalent to `it.only` or `describe.only` {} // the same using regular BDD interface
See the test/index.js
file in this repo for an example
Usage
- Install the package:
npm install --save-dev mocha-exports-ui
- Then just provide the UI name and mocha will automatically require
mocha-exports-ui
:mocha --ui mocha-exports-ui test/index.test.js
TODO:
- should add
let
andconst
to the error output, for instance instead of"before each" hook for "adds variables to the context"
it should say"let" hook for "adds variables to the context"