Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
grunt-qunit-amd
Advanced tools
Grunt plugin to run Qunit tests on your AMD libraries without having to create html pages.
Grunt plugin to run Qunit tests on your AMD libraries without having to create html pages.
This plugin requires Grunt ~0.4.1
(and is not working with node 0.10
)
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-qunit-amd --save-dev
One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-qunit-amd');
In your project's Gruntfile, add a section named qunit_amd
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
qunit_amd: {
unit: function(test){
var config = {
include: [
'test/lib/helper.js',
'test/lib/sinon-1.5.1.js'
],
require: {
baseUrl: 'assets/javascripts/src',
paths: {
jquery: 'public/javascripts/jquery-2.0.0.min',
mustache: 'public/javascripts/mustache',
}
}
}
if (test) {
config.tests = ["test/assets/unit/"+test+".js"];
} else {
config.tests = ["test/assets/unit/*.js"];
}
return config;
}
}
})
#to launch all tests:
grunt qunit_amd:unit
#to launch just one test:
grunt qunit_amd:unit:myTestFileName
Type: Array
An array of files to be injected in all the test suites.
Type: Array
An array of patterns to retrieve the test files. Test files are threated as require.js main files
sample test:
require(['jquery', 'myLibrary'], function($, myLib){
'use strict';
QUnit.start();
module('myLibraryTest', {
setup: function(){
$("<div id='domDependency'></div>").appendTo(document.body);
},
teardown: function(){
document.body.innerHTML = '';
}
})
test('my test', 1, function(){
var myDiv = $('#domDependency');
myLib.setElement(myDiv[0]);
equal(myLib.getElement().id, 'domDependency', "everythings is fine");
});
});
I provided a phantom.log method to be used to log properly to console (HTMLElements already parsed, object already stringified, etc).
Type: Object
In order to take advantage of Istanbul code coverage reporting
coverage: {
out: 'path/to/your/coverage/output/folder',
tmp: 'path/to/a/temp/folder',
pathsToCover: ['glob/to/the/files', 'you/want/coverage/for']
},
Type: Object
QUnit configuration by default QUnit is configured like this:
QUnit.config.blocking = false;
QUnit.config.requireExpects = true;
QUnit.config.autorun = false;
in order to override this settings you need just to pass a config object
qunit :{
requireExpects: false,
autorun: true
}
Type: Object
RequireJS configuration Read the RequireJS documentation
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
This library exists because I've been working with these guys and I learned a lot of stuff about testing: Marco Pracucci, Rocco Zanni, Luca Lischetti
FAQs
Grunt plugin to run Qunit tests on your AMD libraries without having to create html pages.
The npm package grunt-qunit-amd receives a total of 37 weekly downloads. As such, grunt-qunit-amd popularity was classified as not popular.
We found that grunt-qunit-amd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.