The "nutra" module is a simple, extendable unit test runner for node.
Get the "nutra" module up and running with just a few steps.
npm install --save-dev nutra
Nutra recommends Node v4+, as lower versions of node are not being officially supported.
Give this one a try, for now.
Nutra requires presets to be installed with NPM v3+ do to its reliance on a flat dependency tree.
{ // package.json
...
"scripts": {
"test": "nutra --config ./nutra.config.js",
}
...
}
npm run test
For questions about usage (i.e. configuration, plugin development, etc), please post them on StackOverflow and tag it with the keyword "nutra".
For bugs and other unexpected behavior, please post them up on the issue section of this GitHub.
Provide a nutra configuration file:
nutra --config "path/to/nutra.config.js"
The "--config" argument is required Path is relative to the current working directory (cwd).
const nutra = Nutra({
configFile: 'path/to/nutra.config.js', // optional
files: ['test/specs/**/*.js', 'src/**/*.js']
})
nutra.start()
The "config" argument is required. Config path is relative to the current working directory (cwd).
// nutra.config.js
module.exports = function( config ) {
config.set({
// The "files" property allows you to specify the location of your app files and specs.
// It expects an array of globs (https://github.com/isaacs/node-glob) and is always required.
files: ['test/specs/**/*.js', 'src/**/*.js'],
// The "absolutePaths" boolean property allows you to specify whether or not all file paths
// should be treated as absolute. This includes the preprocessor patterns.
absolutePaths: false,
// The "frameworks" property allows you to specify nutra framework plugins, this will typically
// be your test framework (i.e. jasmine, mocha, etc).
frameworks: ['nutra-jasmine'],
// The "preprocessors" property allows you to specify nutra preprocessors plugins, this will
// typically be coverage or transpiling tools (i.e. babel, traceur, typescript, etc).
preprocessors: {
'test/specs/**/*.js': ['nutra-babel'],
'src/**/*.js': ['nutra-babel', 'nutra-coverage']
},
// The "reporters" property allows you to specify nutra reporters plugins, this will
// typically be coverage and other reporting tools.
reporters: ['nutra-coverage'],
// The "{{plugin}}Options" property allows you to specify nutra plugin options, this will
// vary depending on what plugins you are using. An option property for each plugin must
// be specified (i.e. babelOptions: {}, coverageOptions: {}, etc), but it is not required.
coverageOptions: {
dir : './coverage/',
reporters: [
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' }
]
}
})
}
Pull requests are always welcome. In lieu of a formal styleguide, please:
- Take care to maintain the existing coding style.
- Add unit tests for any new or changed functionality.
I get a trill from reinventing a simpler, more efficient wheel.