• PRODUCT

    PRODUCT

  • PRICING
    PRICING

  • HELP
    HELP

  • BLOG
    BLOG

  • APPSTORE
    APPSTORE

  • COMPANY
    COMPANY

  • LEGAL
    LEGAL

  • LOGIN
    LOGIN

  • Workflow Automation

    Workflow Automation

  • AI Assisted Content Management System
    AI Assisted Content Management System

  • Analytics & Lead Generation
    Analytics & Lead Generation

  • Automation Projects
    Automation Projects

  • Browser Extension Apps
    Browser Extension Apps

  • Dashboard Theme Analysis: LN1
    Dashboard Theme Analysis: LN1

  • Data Exchange Automation Tools
    Data Exchange Automation Tools

  • Getting Started With Building Hybrid Apps
    Getting Started With Building Hybrid Apps

  • Izyware Hybrid UX Design Guidelines
    Izyware Hybrid UX Design Guidelines

  • Onboarding New Organizations Using Izyware
    Onboarding New Organizations Using Izyware

  • Quick Visualization and Monitoring
    Quick Visualization and Monitoring

  • Unified Metrics Stream Pipeline
    Unified Metrics Stream Pipeline

  • Legacy Features and Backward Compatibility
    Legacy Features and Backward Compatibility

  • How does the legacy frame architecture work
    How does the legacy frame architecture work

  • Izyware Legacy UI Circus Engine
    Izyware Legacy UI Circus Engine

  • Case Studies and Knowledge Center
    Case Studies and Knowledge Center

  • Angular and React Embedding Guide
    Angular and React Embedding Guide

  • Build and deploy a content distribution app in less than five minutes: Part II
    Build and deploy a content distribution app in less than five minutes: Part II

  • Comparison of CSS Preprocessors SASS vs LESS vs STYLUS
    Comparison of CSS Preprocessors SASS vs LESS vs STYLUS

  • Comparison of node.js test frameworks and utilities: lab, chai, sinon
    Comparison of node.js test frameworks and utilities: lab, chai, sinon

  • Manage and automate your day to day business tools using IzyCloud Tasks: Part I
    Manage and automate your day to day business tools using IzyCloud Tasks: Part I

  • MySql Performance Optimization
    MySql Performance Optimization

  • Onboarding Tutorial: Creating & publishing an app
    Onboarding Tutorial: Creating & publishing an app

  • Rebranding and Customizing Websites
    Rebranding and Customizing Websites

  • Using IzyCloud on Android: IzyCloud Query App
    Using IzyCloud on Android: IzyCloud Query App

  • Technical Resources
    Technical Resources

  • .NET SDKCore IzyWare
    .NET SDKCore IzyWare

  • av-stream README
    av-stream README

  • ElasticSearch IzyWare Data Console Feature
    ElasticSearch IzyWare Data Console Feature

  • End To End Testing
    End To End Testing

  • End To End Testing, Part II
    End To End Testing, Part II

  • frames and nav (ui/w/shell/navmulti) README
    frames and nav (ui/w/shell/navmulti) README

  • izy-circus README
    izy-circus README

  • izy-idman-tools README
    izy-idman-tools README

  • izy-pop3 README
    izy-pop3 README

  • izy-proxy README
    izy-proxy README

  • izy-sync README
    izy-sync README

  • IzyIDE README
    IzyIDE README

  • izymodtask readme
    izymodtask readme

  • IzyShell readme
    IzyShell readme

  • ReKey Feature Package README for IzyWare SQL Console
    ReKey Feature Package README for IzyWare SQL Console

  • Single Sign-On (SSO) README
    Single Sign-On (SSO) README

  • Tasks Migration : V5 guidelines
    Tasks Migration : V5 guidelines

  • Users & Groups README
    Users & Groups README

  • V5 Migration : apps/pulse guidelines README
    V5 Migration : apps/pulse guidelines README

  • Container Orchestration
    Container Orchestration

  • Izy Kubernetes Internal Networking Troubleshooting
    Izy Kubernetes Internal Networking Troubleshooting

  • Application Hosting
    Application Hosting

  • Content Publisher
    Content Publisher

  • Domain Registration
    Domain Registration

  • Email Hosting
    Email Hosting

  • Izyware Browser Extension
    Izyware Browser Extension

  • Izyware Deployment Engine
    Izyware Deployment Engine

  • Izyware Session Management
    Izyware Session Management

  • Messaging System APIs and functionality
    Messaging System APIs and functionality

  • Single SignOn
    Single SignOn

  • Integration APIs
    Integration APIs

  • iOS SDK
    iOS SDK

  • Azure and .NET
    Azure and .NET

  • izy-devops
    izy-devops

  • << Comparison of CSS Preprocessors SASS vs LESS vs STYLUS
    << Comparison of CSS Preprocessors SASS vs LESS vs STYLUS

  • Manage and automate your day to day business tools using IzyCloud Tasks: Part I >>
    Manage and automate your day to day business tools using IzyCloud Tasks: Part I >>

  • Comparison of node.js test frameworks and utilities: lab, chai, sinon

  • Most of IzyCloud customers use Node as the favorite scripting environment. The IzyCloud watch system supports popular node.js test frameworks. However, there is a lot of confusing around lab, chai, sinon and how and why they are used. This article will explain the concepts.

  • Introduction

    Frameworks manage the organization and overall structure of the test rules and test cases. The framework usually uses utility libraries for assertions, spying, etc.

    Frameworks

    The things to consider for analyze the pros and cons of each framework are:

    • Ease of granular testing
    • Aggregate reporting
    • Built in assert functionality vs. reliance on thirdparty
    • code coverage measurement and reporting tools

    AVA (AVAJS)

    Test files are run in parallel as separate processes, giving you even better performance and an isolated environment for each test file and claims to have a better performance that Mocha.

    Syntax is simple:

    import test from 'ava';

    test('arrays are equal', t => {

    t.deepEqual([1, 2], [1, 2]);

    });

    To run only a specific test, use the .only modifier:

    test.only('will be run', t => {

    t.pass();

    });

    Jasmine

    Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean, obvious syntax so that you can easily write tests.

    describe("A suite is just a function", function() {

    var a;

    it("and so is a spec", function() {

    a = true;

    expect(a).toBe(true);

    });

    });

    Mocha

    Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

    var assert = require('assert');

    describe('Array', function() {

    describe('

    indexOf()', function() {

    it('should return -1 when the value is not present', function() {

    assert.equal([1,2,3].indexOf(4), -1);

    });

    });

    });

    Mocha does not have a built in assertion library.

    Lab

    hapijslab is a simple test utility for Node.js. Unlike other test utilities, lab uses only async/await features and includes everything you should expect from a modern Node.js test utility. Our goal with lab is to keep the execution engine as simple as possible, and not try to build an extensible framework.

    lab works with any assertion library that throws an error when a condition isn't met.

    Sometimes it could be hard to trace the failures in large tests. The reporting format is:

    [Checkmark or -] testNumber) test description

    A minus sign would mean that the test case has been marked with skip.

    So, to search and highlight the failures, you could use the following regexp:

    /- [0-9]

    Filtering Test Cases

    To skip a single test, you can change the it expression to:

    it.skip('test case'

    If you would like to select only 1 test case and turn everything else off, use

    it.only('test case'

    Detection
    One way to detect whether the test suit you are analyzing uses lab, is to search for:

    \s[0-9]*)\s

    Also since lab will always report the time spent running the test at the end, you can search for:

    Test duration:\s

    Tap

    node-tap Has a command line interface for running tests and reporting on their success or failure. Also supports test coverage and running tests in parallel.

    It has built-in assertion libraries such as:

    t.ok(obj, message, extra)

    t.ok(obj, message, extra)

    See tap assertions for more info.

    The output is a bit difficult to decipher when the tests get large. The easiest way to track down the errors is to look for test groups that dont have the full number of tests run. i.e.

    tests/myTest.js ..... 18/19

    would indicate an error while

    tests/myTest.js ..... 19/19

    would indicate success.

    Skipping Test Cases
    Detection
    One way to detect whether the test suit you are analyzing uses lab, is to search for:

    ..... [numbers]

    So the regex, would be

    /\.\.\. [0-9]

    Utilities

    sinonjs

    Standalone test spies, stubs and mocks for JavaScript. Works with any unit testing framework. It provides Spies, Stubs, Mocks, Fake timers, Fake XHR and server, JSON-P, Assertions, Matchers, Sandboxes, Utils.

    var callback = sinon.spy();

    var proxy = once(callback);

    proxy();

    assert(callback.called);

    Chai

    Is an assertion library for node and the browser that can be used in the testing framework.

    Chai has several interfaces that allow the developer to choose the most comfortable. The chain-capable BDD styles provide an expressive language & readable style, while the TDD assert style provides a more classical feel

    chai.should();

    foo.should.be.a('string');

    var expect = chai.expect;

    expect(foo).to.be.a('string');

    var assert = chai.assert;

    assert.typeOf(foo, 'string');

    assert.equal(foo, 'bar');

    tap assertions: http://www.node-tap.org/asserts/

    hapijslab: https://github.com/hapijs/lab

    node-tap: http://www.node-tap.org/