Skip to content

Commit

Permalink
adding mocha-require feature. #10
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisabril committed Aug 24, 2016
1 parent f1c0c02 commit 510319c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -48,11 +48,11 @@
"grunt-cli": "^0.1.13",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-watch": "~0.3.0",
"steal": "^0.7.0",
"steal-tools": "^0.7.0",
"steal": "^0.16.35",
"steal-tools": "^0.16.7",
"testee": "^0.2.1"
},
"dependencies": {
"mocha": "^2.2.1"
"mocha": "^3.0.2"
}
}
18 changes: 17 additions & 1 deletion steal-mocha.js
@@ -1,14 +1,30 @@
"format amd";
define(["mocha/mocha", "mocha/mocha.css!"], function(mocha){
define(["mocha/mocha", "@loader", "mocha/mocha.css!"], function(mocha, System){
if(System.mocha) {
var opts = System.mocha;
mocha.setup(opts);
}

var getOpts;


if(System.mochaRequire) {
getOpts = System.import(System.mochaRequire).then(function(mochaConfig) {
return mochaConfig.default || mochaConfig;
});
}
else {
getOpts = Promise.resolve(function() {});
}

steal.done().then(function() {
if (window.Testee) {
Testee.init();
}

return getOpts;
}).then(function(mochaConfig) {
mochaConfig(mocha);
mocha.run();
});

Expand Down
3 changes: 3 additions & 0 deletions test/setup.js
@@ -0,0 +1,3 @@
module.exports = function(mocha) {
mocha.__stealMocha = true;
};
1 change: 1 addition & 0 deletions test/test.html
@@ -1,3 +1,4 @@
<script src="../node_modules/steal/steal.js"
data-mocha="bdd"
data-mocha-require="test/setup"
data-main="test/test"></script>
1 change: 1 addition & 0 deletions test/test.js
Expand Up @@ -4,6 +4,7 @@ describe("A module", function(){

it("A test", function(){
console.assert("it works");
console.assert(mocha.__stealMocha, "require file parsed");
});

});

0 comments on commit 510319c

Please sign in to comment.