question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

including mocha.js in mocha-phantom script

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nathanboktaecommented, Oct 24, 2015

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...
0reactions
nathanboktaecommented, Oct 24, 2015

closing since this is a clarification thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >
mocha-phantomjs error loading resource mocha.js
It's not too ugly to just do: <link rel="stylesheet" href="../node_modules/mocha/mocha.css"> ... <script src=".
Read more >
Getting started with mocha - Medium
Mocha is a great simple testing framework that runs on node.js and within the browser. It's real easy to get set up and...
Read more >
gulp-mocha-phantomjs - npm
run client-side Mocha tests with PhantomJS. ... node_modules/mocha/mocha.js"></script> ... var stream = mochaPhantomJS();.
Read more >
Getting Started with Node.js and Mocha - Semaphore Tutorial
Mocha is a simple, extensible and fast testing library for Node.js. This article will walk you through its installation, configuration and usage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found