Skip to content

Latest commit

 

History

History
166 lines (108 loc) · 4.51 KB

CHANGELOG.md

File metadata and controls

166 lines (108 loc) · 4.51 KB

Changelog

2.1.0 - 2019-01-21

  • Update all dependencies
  • Break changes: The native Number() is an object. So test.number(val) and test.value(val).isNumber() consider the reality, an instance of Number() is an object.

2.0.0 - 2015-04-19

Update Should.js v5.* to v6*.

In should.js@v6 the behavior of should.containDeep* was changed slightly. should.containDeep* does not check substrings anymore. See should.js#42

.contains()

.contains() and .notContains() takes several arguments (instead of an array of arguments). This new behavior is more natural and avoids the ambiguity for test an array or object.

1.2.0 - 2015-04-18

New methods of assertion:

1.0.0 - 2014-09-12

  • Lots of sub-dependencies are removed.
  • No break in the API.
  • New features.
  • Fanatically tested and documented.

Works in the browser

Now we can use Unit.js in the browser ✊

So we can write unit tests with Unit.js for Web applications based on Vanilla JS, jQuery, AngularJS, Backbone.js, ReactJS ... all!

With any runner like Mocha, Jasmine, Protractor (end-to-end test framework for AngularJS applications), QUnit, ... what you want :)

See Unit.js in the browser.

Mocha is no longer included by default.

To use Unit.js with Mocha simply install npm install -g mocha and uses the command mocha <path/of/your/test/directory>

Or npm install mocha --save-dev and add in your package.json:

"scripts": {
  "test": "mocha test"
}

Then uses this command npm test.

See Mocha tutorial in the guide.

New asserters:

New helpers

  • test.promise
  • test.promisify()
  • test.promisifyAll()
  • test.fail()
  • test.stats

See helpers in the guide.

Promise

To keep execution flow organized, Unit.js integrates a mechanism of promise based on the excellent bluebird.

Bluebird is a fully featured promised library with focus on innovative features and performance.

Example:

var fs = test.promisifyAll(require('fs'));

  fs.readFileAsync(require('path').resolve() + '/package.json')
    .when(JSON.parse)
    .then(function(pkg) {
      test
        .object(pkg)
          .hasKey('name', 'unit.js')
          .hasKey('version')

        .value(pkg.version)
          .isGreaterThan('1')
      ;
    })
    .catch(SyntaxError, function(err) {
      test.fail('Syntax error');
    })
    .catch(function(err){
      test.fail(err.message);
    })
    .done()
  ;

Given, when, then are integrated on top of bluebird:

test.promise
  .given($.get('http://www.google.com'))
  .when(function(google) {
    // some states
    // contents = ...
    return $.post('http://localhost/api');
  })
  .then(function(apiPost){
    //some tests
  })
  .catch(function(error) {
    // error handler (you can use test.fail() helper)
  })
  .done()
;

Useful for managing easily the control flow of asynchronous tests.

See promise in the guide.

Dependency injection (DI)

Unit.js supports Dependency Injection (Inversion Of Control).

See dependency-injection in the guide.

Plugins system

Unit.js provides a plugins system (based on Noder.io) for extending Unit.js's assertions and interfaces.

It is possible to create a package works easily as a plugin for Unit.js and also as a standalone module or library.

If you wrote a plugin for Unit.js, please let us know.

See plugins tutorial in the guide.

Documentation

Documentation has been improved.