qunit-inject
QUnit plugin to add dependency injection from module to unit tests.
Example:
QUnit; QUnit;
You can create / modify values to be injected in setup
function
QUnit;// a = 42 in each unit test that needs it
Install
Node:
npm install qunit-inject --save-dev
// load qunit-inject before unit tests
Browser:
bower install qunit-inject
// include the qunit js script first, then
<script src="bower_components/qunit-inject/qunit-inject-browser.js"></script>
// then include user tests
Partial injection
qunit-inject correctly handles assert
argument in each test using
partial injection.
QUnit;QUnit;
Related
Dependency injection implemented using heroin
Other QUnit plugins I made:
Limitation
The injection is not minification safe, since minifier shortens the argument names.
Small print
Author: Gleb Bahmutov © 2014 @bahmutov
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet / open issue on Github