Mocha JavaScript test framework matrix reporter: https://github.com/visionmedia/mocha-matrix

Mocha JavaScript test framework matrix reporter: https://github.com/visionmedia/mocha-matrix

Mocha 1.4.0

This is another relatively small release but still has some goodies!

.only()

By appending .only() Mocha will generate an internal .grep() call for you. This is very useful if you have a regression and a test-case fails. Instead of moving the test-case and associated code out in order to debug you can simply invoke it.only(title, callback) (for the BDD UI) and Mocha will ignore all others. Here’s an example that will execute “bar” and its test-cases only:

describe('foo', function(){
  it('should foo', function(){

  })
})

describe.only('bar', function(){
  it('should bar', function(){

  })
})

.skip()

By appending .skip() you can tell Mocha to ignore these tests. This was previously called xdescribe(), xit() etc to match other frameworks (Jasmine I believe?) but we decided to go with .skip() which is more readable. The jasmine-style functions will remain for now but they will be removed in the future. This is effectively the same as commenting out cases, however they remain in a pending state so that you do not forget to re-enable them.

describe('foo', function(){
  it.skip('should foo', function(){

  })
})

describe('bar', function(){
  it('should bar', function(){

  })
})

Filtering HTML passes and failures

The “passes” and “failures” labels are now clickable links that will filter respectively.

Retina

The canvas progress reporter is now retina-enabled via the autoscale-canvas component. No more ugly pixelated progress!

Changelog

Here’s the full changelog between 1.3 and 1.4:

  • add mkdir -p to mocha init. Closes #539
  • add .only(). Closes #524
  • add .skip(). Closes #524
  • add passes/failures toggling to HTML reporter
  • add pending state to xit() and xdescribe() [Brian Moore]
  • add the @charset “UTF-8”; to fix #522 with FireFox. [Jonathan Creamer]
  • add border-bottom to #stats links
  • add check for runnable in Runner#uncaught(). Closes #494
  • add 0.4 and 0.6 back to travis.yml
  • add -E, --growl-errors to growl on failures only
  • add prefixes to debug() names. Closes #497
  • add Mocha#invert() to js api
  • change str.trim() to use utils.trim(). Closes #533
  • change dot reporter to use sexy unicode dots
  • fix HTML progress indicator retina display
  • fix url-encoding of click-to-grep HTML functionality
  • fix exports double-execution regression. Closes #531
  • fix error when clicking pending test in HTML reporter
  • fix make tm

Mocha 1.3.0

A relatively minor release this time but we’ve still got some cool new features!

Scrolling HTML reporter

The window will now scroll to follow along with larger test suites, and the statistics are fixed to the upper right-hand corner, a small but nice touch.

Custom reporters

Mocha has quite a few bundled reporters now, so future reporters that are not deemed important enough to provide the convenience of being in core should be published to npm. Some less important reporters may be removed from core and published to npm in the future.

This new feature also allows you to use localized private reporters. The --reporter NAME flag now behaves like require(), so for example you could do --reporter ./myreporter, or a third-party npm module such as --reporter lcov-reporter.

For details on creating and finding third-party reporters visit the wiki.

Grep inversion

The awesome --grep feature can now be inverted with the aptly named --invert flag. For example suppose you had tests tagged as @slow, and you wanted to run only slow tests you might use --grep @slow, however if you wanted to run only fast tests --grep @slow --invert would do the trick.

Along with this change --grep PATTERN is now escaped, meaning chars that used to behave as regexp special chars are now escaped.

Changelog

Here’s the full changelog:

1.3.0 / 2012-07-05

  • add window scrolling to HTML reporter
  • add v8 --trace-* option support
  • add support for custom reports via --reporter MODULE
  • add --invert switch to invert --grep matches
  • fix export of Nyan reporter. Closes #495
  • fix escaping of HTML suite titles. Closes #486
  • fix done() called multiple times with an error test
  • change --grep - regexp escape the input

Mocha 1.2.0 - now with more nyan!

Nyan

@atsuya added an awesome new nyan reporter:

Client-side test initialization

You can now initialize a client-side test setup with the mocha init <path> command. This will copy over mocha.css, mocha.js and generate a default tests.html file for you.

Working browser example

A lot of people were asking for a working browser example to reference, so I added one to the bottom of mocha’s site, you can find it here. This example test suite uses chai for assertions.

Wildcard global leaks

Global leak wildcard matching was added to flag globals such as “callback123” and “callback456” with “callback*” created by libraries like jQuery as acceptable since there’s little you can do to avoid this.

mocha 1.1.0

The Mocha javascript test framework version 1.1.0 is out. If you want a quick glance here’s the changelog:

Changelog

  • Added: check each mocha(1) arg for directories to walk
  • Added --recursive [tricknotes]
  • Added context for BDD [hokaccha]
  • Added styling for new clickable titles
  • Added clickable suite titles to HTML reporter
  • Added warning when strings are thrown as errors
  • Changed: green arrows again in HTML reporter styling
  • Changed ul/li elements instead of divs for better copy-and-pasting [joliss]
  • Fixed issue #325 - add better grep support to js api
  • Fixed: save timer references to avoid Sinon interfering.

Directory arguments

Mocha will now iterate the arguments passed and load files in any given directories (non-recursively). For example you may now use mocha spec if you have tests in ./spec instead of mocha spec/* - which is especially helpful for the unfortunate few stuck on windows.

Recursive

The new --recursive flag compliments the previous feature, but walks the directories recursively.

Filter with clickable titles

Suite titles are now clickable, auto-grepping. For example if you have the following suite:

full suite

You could use ?grep=SOMESTRING, or simply click the title to re-execute tests within that suite as shown here:

durations only

That’s it for now :)

Mocha 1.0

The Mocha JavaScript test framework has hit 1.0 with a bunch of great contributions from the community, here’s the change log:

  • Added js API. Closes #265
  • Added: initial run of tests with --watch. Closes #345
  • Added: mark location as a global on the CS. Closes #311
  • Added markdown reporter (github flavour)
  • Added: scrolling menu to coverage.html. Closes #335
  • Added source line to html report for Safari [Tyson Tate]
  • Added “min” reporter, useful for --watch [Jakub Nešetřil]
  • Added support for arbitrary compilers via . Closes #338 [Ian Young]
  • Added Teamcity export to lib/reporters/index [Michael Riley]
  • Fixed chopping of first char in error reporting. Closes #334 [reported by topfunky]
  • Fixed terrible FF / Opera stack traces

Compiler support

coffee-script out of the box was removed, now you can used the --compilers <ext>:<module>,... flag to map a compiler to the given extension name. For example mocha --compilers coffee:coffee-script. There are simply too many foo -> JavaScript transpilers to directly support, this pushes that back on the author.

Min reporter

First up is the min reporter by Jakub Nešetřil, this tiny reporter works great with --watch, outputting the summary only, though still reporting verbose errors on failure.

Markdown reporter

I added a markdown reporter which can be used to display your tests as documentation in a Github wiki page, or simply a markdown file in your repository that you can link to. For example here are the Connect markdown test docs.

I’m not super happy with how much padding Github adds, so the TOC looks pretty messy, but all of these document-style reporting mechanisms make you think twice about how clean and organized your tests are.

JavaScript API

A new JS API was added, which mocha(1) now utilizes. This higher-level JS API will make it easier for those who want to script the testing process with Mocha. I have yet to document this API but it looks like this:

var Mocha = require('mocha');

var mocha = new Mocha;
mocha.reporter('spec').ui('bdd');

mocha.addFile('test/suite.js');
mocha.addFile('test/runner.js');
mocha.addFile('test/runnable.js');

var runner = mocha.run(function(){
  console.log('finished');
});

runner.on('pass', function(test){
  console.log('... %s passed', test.title);
});

runner.on('fail', function(test){
  console.log('... %s failed', test.title);
});