Giter VIP home page Giter VIP logo

enb-bem-node-specs's Introduction

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)

enb-bem-node-specs's People

Contributors

dragn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.