Package Exports
- karma-mocha
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (karma-mocha) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
karma-mocha
Adapter for the Mocha testing framework.
Installation
The easiest way is to keep karma-mocha as a devDependency in your package.json.
{
"devDependencies": {
"karma-mocha": "~0.1"
}
}You can simple do it by:
npm install karma-mocha --save-devInstructions on how to install karma can be found here.
Configuration
Following code shows the default configuration...
// karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['mocha'],
files: [
'*.js'
]
});
};If you want to pass configuration options directly to mocha you can do this in the following way
// karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['mocha'],
files: [
'*.js'
],
client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: 'html',
// require specific files after Mocha is initialized
require: [require.resolve('bdd-lazy-var/bdd_lazy_var_global')],
// custom ui, defined in required file above
ui: 'bdd-lazy-var/global',
}
}
});
};If you want run only some tests matching a given pattern you can do this in the following way
karma start &
karma run -- --grep=<pattern>or
module.exports = function(config) {
config.set({
...
client: {
mocha:{
grep: '<pattern>',
...
}
...
}
});
};The grep argument is passed directly to mocha.
Internals
On the end of each test karma-mocha passes to karma result object with fields:
descriptionTest title.suiteList of titles of test suites.successTrue if test is succeed, false otherwise.skippedTrue if test is skipped.timeTest duration.logList of errors.assertionErrorsList of additional error info:nameError name.messageError message.actualActual data in assertion, serialized to string.expectedExpected data in assertion, serialized to string.showDiffTrue if it is configured by assertion to show diff.
This object will be passed to test reporter.
For more information on Karma see the homepage.