Gathering detailed insights and metrics for karma-mocha
Gathering detailed insights and metrics for karma-mocha
A Karma plugin. Adapter for Mocha testing framework.
npm install karma-mocha
Typescript
Module System
Node Version
NPM Version
99.1
Supply Chain
99.5
Quality
81.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
112,515,603
Last Day
60,406
Last Week
336,521
Last Month
1,415,084
Last Year
14,598,078
MIT License
380 Stars
184 Commits
93 Forks
9 Watchers
80 Branches
45 Contributors
Updated on Jan 27, 2025
Minified
Minified + Gzipped
Latest Version
2.0.1
Package Id
karma-mocha@2.0.1
Size
8.83 kB
NPM Version
6.14.4
Node Version
12.16.3
Published on
Apr 29, 2020
Cumulative downloads
Total Downloads
Last Day
-4.9%
60,406
Compared to previous day
Last Week
0.9%
336,521
Compared to previous week
Last Month
10.3%
1,415,084
Compared to previous month
Last Year
6.8%
14,598,078
Compared to previous year
1
29
Adapter for the Mocha testing framework.
Install karma-mocha
and mocha
into to your project via npm
:
1$ 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:
1$ npm install karma --save-dev
If you're having trouble, Karma provides detailed instructions on installation.
Following code shows the default configuration...
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 frameworks: ['mocha'], 5 6 files: [ 7 '*.js' 8 ] 9 }); 10};
If you want to pass configuration options directly to mocha you can do this in the following way
1// karma.conf.js 2module.exports = function(config) { 3 config.set({ 4 frameworks: ['mocha'], 5 6 files: [ 7 '*.js' 8 ], 9 10 client: { 11 mocha: { 12 // change Karma's debug.html to the mocha web reporter 13 reporter: 'html', 14 15 // require specific files after Mocha is initialized 16 require: [require.resolve('bdd-lazy-var/bdd_lazy_var_global')], 17 18 // custom ui, defined in required file above 19 ui: 'bdd-lazy-var/global', 20 } 21 } 22 }); 23};
If you want run only some tests matching a given pattern you can do this in the following way
1karma start & 2karma run -- --grep=<pattern>
or
1module.exports = function(config) { 2 config.set({ 3 ... 4 client: { 5 mocha: { 6 grep: '<pattern>', // passed directly to mocha 7 ... 8 } 9 ... 10 } 11 }); 12};
If you want to expose test properties specific to mocha
, you can use the expose
option:
1module.exports = function(config) { 2 config.set({ 3 ... 4 client: { 5 mocha: { 6 expose: ['body'] // This will be exposed in a reporter as `result.mocha.body` 7 ... 8 } 9 ... 10 } 11 }); 12};
If you already have a configuration for Mocha in an opts file, you can use the opts
option:
1module.exports = function(config) { 2 config.set({ 3 ... 4 client: { 5 mocha: { 6 opts: 'test/mocha.opts' // You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts' 7 ... 8 } 9 ... 10 } 11 }); 12};
On the end of each test karma-mocha
passes to karma
result object with fields:
description
Test title.suite
List of titles of test suites.success
True if test is succeed, false otherwise.skipped
True if test is skipped.time
Test duration.log
List of errors.startTime
Milliseconds since epoch that the test startedendTime
Milliseconds since epoch that the test endedassertionErrors
List of additional error info:
name
Error name.message
Error message.actual
Actual data in assertion, serialized to string.expected
Expected data in assertion, serialized to string.showDiff
True if it is configured by assertion to show diff.mocha
An optional object listed if you use the expose
optionThis 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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 8/15 approved changesets -- score normalized to 5
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
95 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-03-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More