diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-01-10 20:07:42 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-01-10 20:07:42 +0100 |
commit | 473503a246aa7a23539a349710c5549d1d87c147 (patch) | |
tree | 2b1ee9b420df72a0d861759d1fbcd2226e489086 /extension/test/run_tests.js | |
parent | dd19e0ecbe114ebd71122ff57ea56eabb6258b75 (diff) | |
download | wallet-core-473503a246aa7a23539a349710c5549d1d87c147.tar.xz |
The great modularization.
Use ES6 module syntax and SystemJS modules for everything.
Some testing stubs were added as well.
Diffstat (limited to 'extension/test/run_tests.js')
-rw-r--r-- | extension/test/run_tests.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/extension/test/run_tests.js b/extension/test/run_tests.js new file mode 100644 index 000000000..f62810f7e --- /dev/null +++ b/extension/test/run_tests.js @@ -0,0 +1,55 @@ + +/** + * Bridge between the mocha test runner / nodejs + * and the typescript / the wallet's module system. + * + * The test cases use better-assert as assert library + * with mocha's bdd UI. + */ + +"use strict"; + +let assert = require("better-assert"); +let vm = require("vm"); +let fs = require("fs"); + + +if ("function" !== typeof run) { + throw Error("test must be run with 'mocha --delay ...'"); +} + +console.log("typeof require (here)", typeof require); + +// We might need thins in the future ... +global.nodeRequire = function (modulePath) { + return require(modulePath); +}; + +global.require = global.nodeRequire; + +let data = fs.readFileSync("lib/emscripten/libwrapper.js"); +vm.runInThisContext(data); + +// Do it here, since it breaks 'require'' +let System = require("systemjs"); + +System.config({ + defaultJSExtensions: true +}); + +let mod = System.newModule({Module: Module}); +let modName = System.normalizeSync(__dirname + "/../lib/emscripten/emsc"); +console.log("registering", modName); +System.set(modName, mod); + + +System.import("./test/tests/taler.js") + .then((t) => { + t.declareTests(assert, context, it); + run(); + }) + .catch((e) => { + console.error("failed to load module", e.stack); + }); + + |