|
| 1 | + |
| 2 | +module.exports = { |
| 3 | + run: function() { |
| 4 | + var Mocha = require('mocha'), |
| 5 | + fs = require('fs'), |
| 6 | + path = require('path'); |
| 7 | + |
| 8 | + var mocha = new Mocha(); |
| 9 | + |
| 10 | + var testDir = 'test/'; |
| 11 | + |
| 12 | + // Add each .js file to the mocha instance |
| 13 | + fs.readdirSync(testDir).filter(function(file){ |
| 14 | + // Only keep the .js files |
| 15 | + // TODO: make this a configuration in embark.json |
| 16 | + return file.substr(-3) === '.js'; |
| 17 | + }).forEach(function(file){ |
| 18 | + mocha.addFile( |
| 19 | + path.join(testDir, file) |
| 20 | + ); |
| 21 | + }); |
| 22 | + |
| 23 | + let Test = require('./test.js'); |
| 24 | + |
| 25 | + global.assert = require('assert'); |
| 26 | + //global.Embark = require("../index.js"); |
| 27 | + //global.EmbarkSpec = global.Embark.initTests(); |
| 28 | + |
| 29 | + // TODO: check how to pass the options |
| 30 | + //global.EmbarkSpec = new Test(options); |
| 31 | + global.EmbarkSpec = new Test({}); |
| 32 | + global.web3 = global.EmbarkSpec.web3; |
| 33 | + |
| 34 | + // Run the tests. |
| 35 | + let runner = mocha.run(function(failures){ |
| 36 | + process.on('exit', function () { |
| 37 | + process.exit(failures); // exit with non-zero status if there were failures |
| 38 | + }); |
| 39 | + process.exit(); |
| 40 | + }); |
| 41 | + |
| 42 | + runner.on('suite', function() { |
| 43 | + global.assert = require('assert'); |
| 44 | + //global.Embark = require("../index.js"); |
| 45 | + //global.EmbarkSpec = global.Embark.initTests(); |
| 46 | + // TODO: check how to pass the options |
| 47 | + //global.EmbarkSpec = new Test(options); |
| 48 | + global.EmbarkSpec = new Test({}); |
| 49 | + global.web3 = global.EmbarkSpec.web3; |
| 50 | + }); |
| 51 | + |
| 52 | + } |
| 53 | +} |
| 54 | + |
0 commit comments