Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
atom-mocha-test-runner
Advanced tools
By default, Atom runs your tests with Jasmine (for more information on testing packages in Atom, please see the Atom Flight Manual). Atom allows you to specify a custom test runner using the atomTestRunner
field in your package.json
, but implementing a custom test runner is not straightforward. This module allows you to run your specs using Mocha with minimal fuss.
$ apm install [--save-dev] atom-mocha-test-runner
If you want to use all the default options, simply pass the module name as the atomTestRunner
value in your package.json
:
{
"name": "my-package",
// ...
"atomTestRunner": "atom-mocha-test-runner"
}
Note that your package.json
may be cached by Atom's compile cache when running tests with Atom's GUI test runner, so if adding or changing that field doesn't seem to work, try quitting and restarting Atom. Also note that by default, the runner looks for tests with a .test.js
or .test.coffee
file extension, e.g. my-component.test.js
.
If you'd like to perform more customization of your testing environment, you can create a custom runner while still utilizing atom-mocha-test-runner for most of the heavy lifting. First, set atomTestRunner
to a relative path to a file:
{
"name": "my-package",
// ...
"atomTestRunner": "./test/custom-runner"
}
Then export a test runner created via the atom-mocha-test-runner from test/custom-runner.js
:
var createRunner = require('atom-mocha-test-runner').createRunner
// optional options to customize the runner
var extraOptions = {
testSuffixes: ['-spec.js', '-spec.coffee']
}
var optionalConfigurationFunction = function (mocha) {
// If provided, atom-mocha-test-runner will pass the mocha instance
// to this function, so you can do whatever you'd like to it.
}
module.exports = createRunner(extraOptions, optionalConfigurationFunction)
createRunner([options,] [callback])
Returns a test runner created with the given options
and callback
. Both parameters are optional. The returned value can be exported from your atomTestRunner
script for Atom to consume.
options
- An object specifying customized options:
options.reporter [default: 'dot']
- Which reporter to use on the terminalglobalAtom [default: true]
- Whether or not to assign the created Atom environment to global.atom
testSuffixes [default: ['test.js', 'test.coffee']]
- File extensions that indicate that the file contains testscolors [default: true (false on Windows)]
- Whether or not to colorize output on the terminalhtmlTitle [default: '']
- The string to use for the window title in the HTML reporteratom-mocha-test-runner does not include any assertion libraries; it only includes the Mocha test runner. You can pull in any assertion library you want, but Chai is a great choice.
const assert = require('chai').assert
describe('Testing', function () {
it('works', function () {
assert.equal(answerToLifeUniverseAndEverything, 42)
})
})
FAQs
Run your Atom package tests using Mocha
The npm package atom-mocha-test-runner receives a total of 25 weekly downloads. As such, atom-mocha-test-runner popularity was classified as not popular.
We found that atom-mocha-test-runner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.