(function (mochaAsPromised) { "use strict"; function findNodeJSMocha(moduleToTest, suffix) { if (moduleToTest.id.indexOf(suffix, moduleToTest.id.length - suffix.length) !== -1 && moduleToTest.exports) { return moduleToTest.exports; } for (var i = 0; i < moduleToTest.children.length; ++i) { var found = findNodeJSMocha(moduleToTest.children[i], suffix); if (found) { return found; } } } // Module systems magic dance. if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { // Node.js: plug in automatically, if no argument is provided. This is a good idea since one can run Mocha tests // using the Mocha test runner from either a locally-installed package, or from a globally-installed one. // In the latter case, naively plugging in `require("mocha")` would end up duck-punching the wrong instance, // so we provide this shortcut to auto-detect which Mocha package needs to be duck-punched. module.exports = function (mocha) { if (!mocha) { if (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") { // We're in *real* Node.js, not in a browserify-like environment. Do automatic detection logic. // Funky syntax prevents Browserify from detecting the require, since it's needed for Node.js-only stuff. var path = (require)("path"); var suffix = path.join("mocha", "lib", "mocha.js"); mocha = findNodeJSMocha(require.main, suffix); if (mocha === undefined) { throw new Error("Attempted to automatically plug in to Mocha, but could not detect a " + "running Mocha module."); } } else if (typeof Mocha !== "undefined") { // We're in a browserify-like emulation environment. Try the `Mocha` global. mocha = Mocha; } else { throw new Error("Attempted to automatically plug in to Mocha, but could not detect the " + "environment. Plug in manually by passing the running Mocha module."); } } mochaAsPromised(mocha); }; } else if (typeof define === "function" && define.amd) { // AMD define(function () { return mochaAsPromised; }); } else { // Other environment (usually