Note that there are some explanatory texts on larger screens.

plurals
  1. POmocha init timeout with mocha-phantomjs
    primarykey
    data
    text
    <p>I have the following <code>testrunner.html</code>:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Specs&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;link rel="stylesheet" href="/content/css/mocha.css" /&gt; &lt;script&gt; function assert(expr, msg) { if (!expr) throw new Error(msg || 'failed'); } &lt;/script&gt; &lt;script src="/client/lib/require.js" type="text/javascript" data-main="/client/specs/_runner.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="mocha"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The <code>_runner.js</code> looks like this:</p> <pre><code>// Configure RequireJS require.config({ baseUrl: '/client', urlArgs: "v=" + (new Date()).getTime() }); // Require libraries require(['require', 'lib/chai', 'lib/mocha'], function (require, chai) { // Chai assert = chai.assert; should = chai.should(); expect = chai.expect; // Mocha mocha.setup('bdd'); // Require base tests before starting require(['specs/stringcalculator.specs'], function (person) { mocha.setup({ globals: ['hasCert'] }); // Start runner if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { mocha.run(); } }); }); </code></pre> <p>The <code>StringCalculator.specs.js</code> is this:</p> <pre><code>define(['app/model/StringCalculator'], function () { describe("StringCalculator", function () { describe("when an empty string is passed in", function () { it("returns 0", function () { var result = StringCalculator.add(""); assert(result === 0); }); }); describe("when a number is passed in", function () { it("returns the number", function () { var result = StringCalculator.add("2"); assert(result === 2); }); }); describe("when string is passed in", function () { it("returns NaN", function () { var result = StringCalculator.add("a"); assert(isNaN(result)); }); }); describe("when '1,2' is passed in", function () { it("returns 3", function () { var result = StringCalculator.add("1,2"); assert(result === 3); }); }); }); }); </code></pre> <p>And this is the <code>StringCalculator.js</code> itself (from the mocha samples):</p> <pre><code>define([], function() { window.StringCalculator = StringCalculator = { add: function(inputString) { if (inputString === '') { return 0; } var result = 0; var inputStrings = inputString.split(','); for (var i = 0; i &lt; inputStrings.length; i++) { result += parseInt(inputStrings[i]); } return result; } } }); </code></pre> <p>When running the specs in a browser calling <code>testrunner.html</code>, everything works as expected. When running <code>mocha-phantomjs client/specs/testrunner.html</code> on OS X, I get the following error:</p> <p><code>Failed to start mocha: Init timeout</code></p> <p>What may I'm missing here?</p> <p>I also tried <code>mocha-phantomjs http://httpjs.herokuapp.com</code> which fails with the same error.</p> <p>Update: If I'm calling <code>mocha-phantomjs http://localhost:81/client/specs/testrunner.html</code> I also get the following error on the console:</p> <pre><code>RangeError: Maximum call stack size exceeded. http://localhost:81/client/lib/chai.js?v=123423553533535:2601 Failed to start mocha: Init timeout </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload