Questions tagged [chai]

Chai is a BDD/TDD assertion library for Node.js and browsers that can be used with any Javascript testing framework.

Chai is a / assertion library for and that can be used with any testing framework.

2953 questions
1
vote
0 answers

Assertions in callbacks created by promises timing out

I have a piece of middleware that checks a users authentication based on a passed parameter. The middleware uses a model that implements promises to find and return the user to be set into the request params. The problem is, when running tests, if…
nullfox
  • 597
  • 1
  • 4
  • 16
1
vote
1 answer

Mocha passing tests in browser, failing on command line

I'm using mocha-grunt to be able to run/see my client side tests on the command line. For some reason, it seems that decrementColumn is being called twice when I run my tests on the command line. I wonder if some sort of phantomJS window scoping…
Salar
  • 861
  • 9
  • 13
1
vote
2 answers

How can I stub a jQuery method with Sinon?

I have the following code in an Ember View: postRender: -> @_super() @$().tooltipster({ content: @$().data('tooltip') contentAsHTML: true }) I'm trying to test that tooltipster() is called when postRender() executes but…
spinlock
  • 3,737
  • 4
  • 35
  • 46
1
vote
1 answer

How can mocha know when event fired on a Controller $scope using $broadcast inside of a $promise?

I could not find any other question/answer that met my needs, so here it is: In an AngularJS (1.2.14) controller, I have an event listener that executes an ajax call to fetch some data when an event ('fetchData') is heard. After the fetch is…
Ryan Conaway
  • 446
  • 2
  • 10
1
vote
1 answer

Yeoman webapp generator - How to run mocha tests in the Browser

I've got some JS tests written in mocha/chai and I would like to run them in a project scaffolded using the webapp generator. I've put my tests inside the "test" folder from Yeoman's structure and the tests are running fine. But the issue is that…
darksoulsong
  • 13,988
  • 14
  • 47
  • 90
1
vote
0 answers

WebDriver / Sauce Labs / Chai / chai-as-promise Documentation?

I've got a scenario testing setup going with Sauce Labs, WebDriver, I'm including chai and the chai-as-promise library. I've been pulling bits and pieces out of examples and have got as far as: require('colors'); var chai = require('chai'); var…
nicholas
  • 14,184
  • 22
  • 82
  • 138
1
vote
2 answers

throuble with doing unit testing in chaijs about expect.throw

I'm using chaijs with mochajs for unit-testing. This is the doc of chaijs. http://chaijs.com/api/bdd/ according with the documentation, it can check if function throws an Exception. So, with this code: var expect =…
alexserver
  • 1,348
  • 3
  • 15
  • 30
1
vote
2 answers

Socket.io and testing with mocha

I am using Mocha and chai for client testing of a small app that I wrote. However, I have run into a problem where even though I know my socket is connected, mocha reports that it isn't. I have looked around and can't seem to find something that…
robotmayo
  • 131
  • 10
1
vote
1 answer

NodeJS "make test" returns a Permission denied

I'm trying to test my NodeJS app using Mocha and Chai, however I'm getting this error : root@xxxx-Vostro-1540 : sraperproject # make test /bin/sh: 1: ./node_modules/.bin/mocha: Permission denied make: *** [test] Error 126 root@xxxx-Vostro-1540 :…
devio
  • 1,147
  • 5
  • 15
  • 41
1
vote
2 answers

Angular testing a directive - find doesn't work as expected (or at all?)

I have this directive. it gets an array and creates a stacked bar. while the directive works fine, the unittesting failes miserably. I tried: describe('Stacked bar directive', function(){ var scope, elem; …
alonisser
  • 11,542
  • 21
  • 85
  • 139
1
vote
4 answers

Is there a way to improve the floating point precision of this expression?

I have an expression that is used to estimate percentiles by interpolating between two values. windowMin + (currentPercentile - lastPercentile) * (windowMax - windowMin) / (percentile - lastPercentile) This has given me very good real-world…
1
vote
1 answer

Mocha in the browser: How to get a report using chai.assert

I can't get Mocha to produce output when using chai.assert. http://jsfiddle.net/web5me/244PT/6/ var assert = chai.assert(); mocha.setup('bdd'); describe('Kata', function() { it('should return...', function() { assert.equal(true, true,…
Marc Diethelm
  • 1,182
  • 1
  • 11
  • 15
1
vote
1 answer

Event is not catched in my test with stubbed function

I'm running a problem I don't get. The event I emit is not catched in my test. Here is the following code (event.js): var util = require('util'), proc = require('child_process'), EventEmitter = require('events').EventEmitter; var Event =…
xavier.seignard
  • 11,254
  • 13
  • 51
  • 75
1
vote
1 answer

Make function wait before getting and returning DOM element

Doing some headless testing using Mocha > Chai > PhantomJS. Everything is setup and working, but I'm trying to fill a form with bad credentials, and then check to see that a DOM element is created. What I want to do is basically this: it('should…
dropknow1edge
  • 55
  • 1
  • 7
1
vote
2 answers

How to test the Node js application with mocha-phantomjs

I need to test my Node js apllication with mocha-phantomjs.I have tried the below code to test the app but i'm getting error as 'ReferenceError: Can't find variable: require'.How to resolve this. test.html Tests
sachin
  • 13,605
  • 14
  • 42
  • 55
1 2 3
99
100