including mocha.js in mocha-phantom script
See original GitHub issueI 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:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah, the issue is actually nathanboktae/mocha-phantomjs-core#12, sorry about that.
But do what it says and call
window.initMochaPhantomJS()before callingmocha.setupor other setup functionsclosing since this is a clarification thread.