enb-bem-node-specs

0.0.5 • Public • Published

enb-bem-node-specs

Automatic spec tests for node.js BEM-blocks with ENB.

The test are described similar to enb-bem-specs.

Tests are written in mocha style with chai framework included. Chai's expect and assert are also available on global scope.

Example test looks like this:

modules.define('spec', ['block'], function(provde, block) {
 
    // .. usual mocha test description:
    describe('block', function() {
        it('should rock', function() {
            // using chai's expect
            expect(block).to.be.defined;
 
            // using chai's assert
            assert.isDefined(block);
 
            // using chai's should
            block.rocks().should.be.true;
        });
    });
 
    provide();
});

Usage

First, install npm module:

npm install --save enb-bem-node-specs

Then, to add enb-bem-node-specs to your ENB project do something like this in .enb/make.js:

...
module.exports = function(config) {
    ...
    config.includeConfig('enb-bem-node-spec');
 
    // 'specs' is the enb task name, you may change it if you like
    var nodeSpecConfig = config.module('enb-bem-node-specs').createConfigurator('specs');
    nodeSpecConfig({
        destPath: 'server.specs', // where to put specs
        levels: ['server.blocks'] // where are blocks' source codes located
    });
}

To run specs, execute task specs (or whichever task name you configured in make.js):

node_modules/.bin/enb make specs

Coverage

enb-bem-node-specs supports code coverage measure with istanbul To enable it, add coverageFile option in make.js:

...
module.exports = function(config) {
    ...
    config.includeConfig('enb-bem-node-spec');
 
    // 'specs' is the enb task name, you may change it if you like
    var nodeSpecConfig = config.module('enb-bem-node-specs').createConfigurator('specs');
    nodeSpecConfig({
        destPath: 'server.specs', // where to put specs
        levels: ['server.blocks'], // where are blocks' source codes located
        coverageFile: 'coverage.json'
    });
}

Coverage info will be merged into provided file, which helps to use enb-bem-node-specs with other tasks (enb-bem-specs, for example, also uses coverage.json)

Readme

Keywords

none

Package Sidebar

Install

npm i enb-bem-node-specs

Weekly Downloads

1

Version

0.0.5

License

MIT

Last publish

Collaborators

  • dsabelnikov