This also adds Python-2.0 to the list of accepted licenses. Lastly, it fixes a bug where the package.json files were incorrectly reordered. For the `exports` of a particular package, the order that the entrypoints are defined in is crucial. Therefore, we should not alter the order of entrypoints and instead maintain the originally defined ordering. We can use an `OrderedDict` to ensure that Python always loads the JSON files in the same order. DISABLE_THIRD_PARTY_CHECK=NPM update R=jacktfranklin@chromium.org Bug: none Change-Id: I5a309782de6015edea6ba3b502aa0db1f008d973 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2692909 Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
karma-mocha
Adapter for the Mocha testing framework.
Installation
Install karma-mocha and mocha into to your project via npm:
$ npm install karma-mocha mocha --save-dev
karma-mocha should work with any version of mocha.
Since karma-mocha is an adapter for Karma, you likely have it installed already, but in case you don't:
$ npm install karma --save-dev
If you're having trouble, Karma provides detailed instructions on installation.
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>', // passed directly to mocha
...
}
...
}
});
};
If you want to expose test properties specific to mocha, you can use the expose option:
module.exports = function(config) {
config.set({
...
client: {
mocha: {
expose: ['body'] // This will be exposed in a reporter as `result.mocha.body`
...
}
...
}
});
};
If you already have a configuration for Mocha in an opts file, you can use the opts option:
module.exports = function(config) {
config.set({
...
client: {
mocha: {
opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts'
...
}
...
}
});
};
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.startTimeMilliseconds since epoch that the test startedendTimeMilliseconds since epoch that the test endedassertionErrorsList 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.
mochaAn optional object listed if you use theexposeoption
This object will be passed to test reporter.
NB. the start and end times are added by the adapter whereas the duration is calculated by Mocha - as such they probably will not match arithmetically. Ie. endTime - startTime !== duration. These fields have been added so that timestamped reports can be matched up with other timestamped reports from the target device (eg. memory profiling data collected outside the browser)
For more information on Karma see the homepage.