Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/peerigon/nof5

A tool which runs unit tests (based on mocha) if a file has changed on the server in a browser
https://github.com/peerigon/nof5

Last synced: 9 days ago
JSON representation

A tool which runs unit tests (based on mocha) if a file has changed on the server in a browser

Lists

README

        

# nof5

is a server that runs **Unit Tests** with the help of test-suites like

- [QUnit](http://qunitjs.com/) or
- [Mocha](http://visionmedia.github.com/mocha/)

on any number of mobile or desktop browsers simultaneously and automatically.
nof5 is independent of these test suites and can be used with any suite.
Therefore is should be simple to integrate nof5 with existing tests.
nof5 is based on

- [express](http://expressjs.com/) and
- [socket.io](http://socket.io/)

It also supports *Web-Bundler*s such as

- [browserify](https://github.com/substack/node-browserify) or
- [webpack](https://github.com/webpack/webpack)

and can be customized to one's own needs with the help of **Hooks** as

- before
- beforeEach

Additionally nof5 supports the **xUnit** format and can therefore be integrated in **Continuous Integration** servers such as

- [Jenkins](http://jenkins-ci.org/)

## Motivation

We originally built nof5 for our client-and server-side framework [alamid.js] (http://alamidjs.com/).
[alamid.js] (http://alamidjs.com/) makes it possible that the client code can be written exactly as for the server.
We use for the classes of [alamid.js] (http://alamidjs.com/) our JavaScript compiler [nodeclass] (https://npmjs.org/package/nodeclass)
and the client-side code will be bundled with the help of [WebPack] (https://github.com/webpack/webpack).
We also develop [alamid.js](http://alamidjs.com/) using Contiuous integration and Jenkins.
There was no tool that combines all these technologies.

## Installation

npm install -g nof5

## Options

Usage: nof5 [options]

-h, --help output usage information
-V, --version output the version number
-d, --debug outputs some additional debug output, such as a list of watched folders
-s, --silent run without console logging
--list lists all bundler names
-p, --port server port. Default: 11234
-t, --test path to test folder. Default: process.cwd()
-l, --lib path to lib folder
-a, --assets path to folder where additionally files should be also served as statics
-b, --bundler defines the bundler which should be used. Default: 'Webpack'
-H, --hooks path to file with hooks
-W, --wphooks path to file with hooks for webpack-bundler
-B, --bhooks path to file with hooks for browserify-bundler
-x, --xunit path to store xunit.xml file.
-c, --clients use given client hook

## How to use

### start nof5

Just execute on command line from test's root folder nof5 or from anywhere nof5 -t path/to/test/folder

### hooks

#### define general hooks (optional)

Define a file named nof5.hooks.js under test's root folder or pass the path to the hooks-file nof5 -H path/to/hooks/file

The hooks-file should look like this:

```javascript

exports.before = function beforeHook() {
//will be executed once
}

exports.beforeEach = function() {
//will be executed each time
}

```

#### define webpack hooks (optional)

Define a file named nof5.webpack.hooks.js under test's root folder or or pass the path to the webpack-hooks-file nof5 -W path/to/webpack/hooks/file

The webpack-hooks.file should look like this:

```javascript

exports.use = function () {

return {
// webpack-options @see https://github.com/webpack/webpack#options
};

}

```

#### define browserify hooks (optional)

Define a file named nof5.browserify.hooks.js under test's root folder or or pass the path to the browserify-hooks-file nof5 -B path/to/browserify/hooks/file

The webpack-hooks.file should look like this:

```javascript

exports.use = function () {

"middlewareA": function () {
//@see https://github.com/substack/node-browserify/blob/master/doc/methods.markdown#busefn
},

"middlewareB": function () {
// ...
}
}

```

### Create a Test-Runner

All files under root-folder are served as static files by nof5, so you can use any assets you like, e.g. jQuery, QUnit or Mocha.

```html




//configure your test-runner

nof5.enableTests()

```

See also the example implementation of a [Test-Runner](https://github.com/peerigon/nof5/blob/master/example/webpack/assets/testRunner.js).

### Use with Jenkins

TODO