I'm using Mocha with RequireJS and tests are running fine, however, when I try to add in blanket code coverage I'm getting Uncaught TypeError: Object #<HTMLDivElement> has no method 'reporter'
,
Here's the code I'm running:
<div id="mocha"></div>
<script src="../src/js/vendor/requirejs/require.js"></script>
<script src="../src/js/vendor/blanket/dist/qunit/blanket.js"
data-cover-adapter="../src/js/vendor/blanket/src/adapters/mocha-blanket.js"></script>
<script src="SpecRunner.js" data-cover></script>
and my specrunner:
require(["../src/js/require-config.js"], function () {
// Set testing config
require.config({
baseUrl: "../src/js",
paths: {
"mocha": "vendor/mocha/mocha",
"chai": "vendor/chai/chai"
},
urlArgs: "bust=" + (new Date()).getTime()
});
require([
"require",
"chai",
"mocha"
], function (require, chai) {
var should = chai.should();
mocha.setup("bdd");
require([
"specs.js",
], function(require) {
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
});
});
});
Like I said - my tests are all running fine, I just can't figure out why blanket's not working.
Update:
I can get it to run by including the script tag for mocha at the beginning, however, now it runs the mocha tests twice.
I figured it out and did a write-up on getting Blanket to work with Mocha in AMD. Here's a blog post outlining the process as well as a repo with the working code.
I'm using the following to load my tests:
And then the following code on the page: