Closed bmark1111 closed 9 years ago
You need to provide a reference to an HTML file. This is not node or phantomjs code here.... Please read the readme carefully and see the examples. On Oct 14, 2015 10:35 AM, "bmark1111" notifications@github.com wrote:
I have the following mocha-phantomjs script:
var chai = require("vendor/chai"); var mocha = require('vendor/mocha'); mocha.ui('bdd'); mocha.reporter('html'); var expect = chai.expect;
describe("Simple", function() { describe("constructor", function() { it("a simple test", function() { var test = 1 + 1; expect(test).to.equal(2); phantom.exit(); }); }); });
I keep getting the following error when running this from the command line:
mocha-phantomjs phantomtest.js
mocha was not initialized before the page finished loading. Make sure to include mocha.js as a direct script and call mocha.ui or mocha.setup.
What am I doing wrong.
Thanks for your help
— Reply to this email directly or view it on GitHub https://github.com/nathanboktae/mocha-phantomjs/issues/213.
Oh I see. I'm new to mocha-phantomjs so if you could just bear with me. When I run with my html test runner I get this error:
mocha-phantomjs v1.html
Error loading resource file:.............................. Details: Request for opening non-local file file:...............
Read through all the examples and README. Sorry but still cant see an answer to my issue.
Dobyour tests run when you open v1.html
in a browser?
yes they run fine
Resources errors don't necessarily mean your tests failed, and you'd see the same output in the console as you do in a browser. I can't really tell exactly from the information you provided.
Likely due to external resource loading and timing, your tests require calling window.initMochaPhantomJS()
before calling any mocha setup functions. See https://github.com/nathanboktae/mocha-phantomjs/issues/213
how can i fix this problem
Ah, the issue is actually nathanboktae/mocha-phantomjs-core#12, sorry about that.
But do what it says and call window.initMochaPhantomJS()
before calling mocha.setup
or other setup functions
window.initMochaPhantomJS && window.initMochaPhantomJS()
mocha.setup('bdd') // or whatever, mocha.ui('tdd'), mocha.slow(), etc etc...
closing since this is a clarification thread.
I have the following mocha-phantomjs script:
var chai = require("vendor/chai"); var mocha = require('vendor/mocha'); mocha.ui('bdd'); mocha.reporter('html'); var expect = chai.expect;
describe("Simple", function() { describe("constructor", function() { it("a simple test", function() { var test = 1 + 1; expect(test).to.equal(2); phantom.exit(); }); }); });
I keep getting the following error when running this from the command line:
mocha-phantomjs phantomtest.js
mocha was not initialized before the page finished loading. Make sure to include mocha.js as a direct script and call
mocha.ui
ormocha.setup
.What am I doing wrong.
Thanks for your help