Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
grunt-contrib-nodeunit
Advanced tools
Run Nodeunit unit tests
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-contrib-nodeunit --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-contrib-nodeunit');
Run this task with the grunt nodeunit
command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
This plugin provides server-side JavaScript unit testing via nodeunit. If you're looking to test JavaScript that uses window
or the DOM, please use the grunt-contrib-qunit pluginqunit
task.
There may be a few differences versus running nodeunit
on the command line:
Nodeunit's reporters (such as default
) are in charge of tracking tests that do not complete. They often hook
into process.on('exit')
. Since grunt
is handling the runtime, it does not exit, so the reporter's clean-up code
that monitors undone tests does not fire. Additionally, the reporters do not expose the number of "Undone" tests in their
completion callbacks.
This can cause problems. For example, if an exception is thrown in an undone test, the exception might bubble up into the
grunt
runtime if it's still running. This would cause grunt
to exit, while nodeunit
command line would show the undone
test.
If you're getting strange grunt
runtime errors or seeing grunt
exit, check for "undone" tests.
Type: String
Default: 'grunt'
Specifies the reporter you want to use. For example, default
, verbose
or tap
.
Type: Boolean
Default: false
Specifies the file the reporter
's output should be saved to. For example, tests.tap
.
Type: Object
Default: {}
Specifies the options passed to the reporter
. For example, the junit
reporter requires the output
option
to be set:
grunt.initConfig({
nodeunit: {
all: ['test/*_test.js'],
options: {
reporter: 'junit',
reporterOptions: {
output: 'outputdir'
}
}
}
});
In this example, grunt nodeunit:all
or grunt nodeunit
will test all files ending with _test.js
in the test
directory.
grunt.initConfig({
nodeunit: {
all: ['test/*_test.js']
}
});
With a slight modification, grunt nodeunit:all
will test files matching the same pattern in the test
directory and all subdirectories.
grunt.initConfig({
nodeunit: {
all: ['test/**/*_test.js']
}
});
To use a reporter other than the default one, you can specify the reporter
and reporterOutput
parameters.
grunt.initConfig({
nodeunit: {
all: ['test/*_test.js'],
options: {
reporter: 'tap',
reporterOutput: 'tests.tap',
reporterOptions: {
output: 'outputdir'
}
}
}
});
error.stack
exists.reporter
and reporterOutput
options.this.filesSrc
API.this.file
API internally.Task submitted by "Cowboy" Ben Alman
This is a generated file.
FAQs
Run Nodeunit unit tests
The npm package grunt-contrib-nodeunit receives a total of 3,631 weekly downloads. As such, grunt-contrib-nodeunit popularity was classified as popular.
We found that grunt-contrib-nodeunit 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.