Questions tagged [mocha-phantomjs]

Mocha is a feature-rich JavaScript test framework running on node and the browser.

The mocha-phantomjs project provides a mocha-phantomjs.coffee script file and extensions to drive PhantomJS while testing your HTML pages with Mocha from the console. The preferred usage is to install mocha-phantomjs via node's packaged modules and use the mocha-phantomjs binary wrapper.

57 questions
26
votes
11 answers

No binary for PhantomJS browser on your platform. Please, set "PHANTOMJS_BIN" env variable

My package.json looks like this.. "karma-phantomjs-launcher": "^0.1.4", "karma-safari-launcher": "^0.1.1", "karma-sinon-chai": "~0.2.0", "karma-spec-reporter": "~0.0.16", "mocha": "~1.20.1" my npm version is 2.2.0 whay am I getting this when I run…
Sanath
  • 4,774
  • 10
  • 51
  • 81
26
votes
4 answers

npm error ELIFECYCLE while running the test

I am using mocha-phantomjs setup for unit testing. I have following package.json scriot to run the tests. "scripts": { "test": "npm run testFlickr", "testFlickr": "mocha-phantomjs ./test/FlickrTest.html" } This run ok in browser. And when I run…
user3115091
8
votes
4 answers

How to make mocha fail when no expect within it()

Is there an option to set mocha to report test as failing in case no expect provided within it() function? Idea is workflow to be like this: add one it() with desc and callback function the it() is reported as fail since no expectation is set in…
gee6
  • 83
  • 5
5
votes
1 answer

ERROR: '[Vue warn]: Failed to resolve directive: in testing

I am writing unit tests in a Vue 2.0 app using PhantomJS, Karma, Mocha and Chai and while the tests pass, I get a warning with each test that looks like this: ERROR: '[Vue warn]: Failed to resolve directive: highlightjs (found in ) I…
5
votes
1 answer

How to run code coverage for client side javascript code using grunt

How can I run code coverage for client side javascript code using grunt? I have run the client side javascript code test using mocha-phantomjs to be tested using html page, and it works fine, but I couldn't find a way to run code coverage for it. It…
5
votes
1 answer

timeout of 2000ms exceeded mocha

I have two test cases i.e. it("should pass with..").. and it("should fail with..").., When I test this it gave timeout of 2000ms exceeded error. describe("flickrphotoSearch", function () { it("should pass with correct inputs", function (done) { …
user3115091
4
votes
2 answers

run all 'test.html' files in a directory - mocha-phantomjs

I have a module, I am testing this module using mocha-phantomjs. I created package.json file { "name" : "demo-test", "scripts": { "test": "npm run test-debug", "test-debug": "mocha-phantomjs ./test/Test1.html" }, …
user3115091
3
votes
2 answers

How to handle async test in Mocha?

I have an event handler function that takes some event data and a callback function as input. This event handler is using a promise to do its job: function myHandler(event, callback) { somePromise(event).then((result) => { if (result.Error) { …
Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74
3
votes
2 answers

Testing chrome extension - require error

I have this gulp task: gulp.task('test', function () { return gulp.src('test/runner.html') .pipe(mochaPhantomJS()); }); This is my runner.html: Mocha
Cornwell
  • 3,304
  • 7
  • 51
  • 84
3
votes
1 answer

Mochajs external script onload test

I am trying to create a mochajs test to detect the script.onload event has been executed or the script.onerror. I have setup tests to detect the script exists in the DOM but am not sure how to check the actual loading. describe("Load external ABC…
user1572796
  • 1,057
  • 2
  • 21
  • 46
3
votes
3 answers

How to configure resource handling by mocha-phatomJS? Error loading resource file:

I'm running test using mocha-phantomjs. While running an unit test, I'm not running http server, so my resources are not available through absolute urls (eg: /static/images/face.png), and I'm getting following output: %…
Robert Zaremba
  • 8,081
  • 7
  • 47
  • 78
3
votes
1 answer

mocha-phantomjs test case for callback function

I have a module in which I have this function flickrPhotoSearch: function (searchByName, flickrUserKey, numberOfImages, callbackData) { return $.ajax({ url: commonConstants.BASE_URL + "flickr.photos.search&api_key=" + flickrUserKey +…
user3115091
2
votes
1 answer

Grunt: How to correctly setup .html file for mocha testing?

I am new to grunt and tests and currently I have setup like this: Grunt running tasks after which I have build folder where I have my compiled index.html and all his resources (css, js, images) Now I want to run tests using grunt-mocha-phantomjs and…
neryonc
  • 31
  • 3
2
votes
0 answers

Testing DOM, Phantom, Sinon, Mocha - How to check if element was clicked

I need test if text on the button was change, after click. But I can't find anywhere - how to do it. Please help :(, I run test mocha-phantomjs TestRunner.html My code is : TestRunner.html …
Agata
  • 554
  • 1
  • 9
  • 18
2
votes
1 answer

Sinon mock expects().withExactArgs(function() {}) returns once (never called)

Code : Model = {}; var functionToTest = function (dataPoints) { return Model.getDataPointValue(dataPoints, function (dataPoint) { if (dataPoint.unit === 'unit') { return dataPoint.value; } …
1
2 3 4