You can edit almost every page by Creating an account and confirming your email.

Unit.js

From EverybodyWiki Bios & Wiki

Unit.js
File:Unit JS logo.png
Developer(s)Nicolas Tallefourtane
Stable release
2.1.1 / October 18, 2019; 6 years ago (2019-10-18)
Written inJavaScript
Engine
    Operating systemCross-platform
    TypeUnit Test
    LicenseAGPL 3
    Websitehttps://unitjs.com

    Search Unit.js on Amazon.

    Unit.js is an open source unit testing framework for the JavaScript programming language,[1] running on Node.js and the browser.

    Usage

    A simple hello world test looks like the code below.

      var example = 'Hello world!';
    
      test.string(example)
        .isEqualTo('Hello world!');
    

    Support describe() and it(), describes a suite of tests and it() is an individual test specification. The name "it()" follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence.

    describe('Hello world', function() {
      it('says hello', function() {
    
        var example = 'Hello world!';
    
        test.string(example)
         .isEqualTo('Hello world!');
      });
    });
    

    Assertion styles

    Unit.js has multiple interfaces that allow the developer to choose the most comfortable and productive style.

    Unit.js :

    test.string(str)
      .number(num).is(42);
    

    Assert :

    test.assert(typeof str === 'string');
    test.assert(typeof num === 'number');
    test.assert.equal(num, 42);
    

    Must.js :

    test.must(str).be.a.string();
    test.must(num).be.a.number();
    test.must(num).equal(42);
    

    Should.js :

    test.should(str).be.a.String
    test.should(num).be.Number
    .and.equal(42);
    

    See also

    References

    1. "Unit testing framework for Javascript - Unit JS". unitjs.com.

    External links


    This article "Unit.js" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:Unit.js. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.