Questions tagged [mocha]

Mocha is a feature-rich JavaScript test framework running on node.js and the browser. Mocha allows you to use any assertion library you want, if it throws an error, it will work. This means you can utilize libraries such as should.js, node's regular assert module, or others.

Filter by
Sorted by
Tagged with
-2
votes
1answer
23 views

Mocha with overlapping tests [closed]

Fairly new to writing tests. I hoping to get feedback about test writing. I am curious to know if there is a convention/standard for short is better or more informative is better? A) expect(mqError)....
1
vote
1answer
134 views

Mocha + chai tests

I have been making an effort to add a fair amount of unit testing into my code. However, I find myself going against the DRY principle quite a bit. I am currently running tests on my API with my ...
1
vote
1answer
74 views

Unit tests for a simple function thats part of a public API [closed]

Given I have to write a simple function that essentially just does a http-fetch to the given URL but is part of a public API that will be used by thousands. I have two main questions about the ...
1
vote
1answer
59 views

Javascript assignment as expression in fat-arrow one-liner [closed]

I have a promise where I'm taking the eventual result from the callback and storing it in a value that's scoped outside of the current block in a before hook, all ...
2
votes
2answers
1k views

RESTful CRUD application API Unit Tests

So I am trying to learn TDD/BDD with Javascript. I am creating a simple RESTful web app that uses GET, POST, PUT, and DELETE API calls to update data in a MongoDB database, and wanted to see if there ...
6
votes
1answer
142 views

Support static typing / analysis with dependency injection

I am working on creating a test library, and I found DI to be pretty convenient, maybe even to create more functional coding patterns. Normally we can have an awkward before-hook setup in Node.js ...
1
vote
0answers
83 views

Unit testing for sending messages

I'm new to testing in Meteor, so I'm worried if my implementation is not going in the right directions. I've written a unit test for my send method which sends a ...
10
votes
1answer
158 views

A Makefile to make some Cheese

Excuse the pun in the title, the project this is for is called "Cheddar" (a type of cheese). Github I have recently been writing a language, in which I was using grunt. Grunt was very slow for me, ...
13
votes
1answer
235 views

Generate a URL, shorten it, insert it in a tex file and compile those tex files

I have written a NodeJS module and its tests to generate a URL, shorten it with Bitly, insert the short link in a tex file, compile these tex files to PDF and then merge them into one. The code is ...
1
vote
0answers
31 views

Run code after making a certain number of requests using RxJS

I'm experimenting with reactive JS by writing mocha tests. I wrote a test that makes a certain number of requests to an API before stopping. However, this being my first experience with RxJS, I don't ...
15
votes
2answers
5k views

Test mongoose model

I have mongoose model: ...
7
votes
2answers
484 views

Am I implementing BDD correctly?

I'm writing a utility that validates fields. I decided to try my hand at Behaviour Driven Development (BDD). The validator utilises "rules" to determine if field is valid. Three different types of ...
4
votes
1answer
82 views

Testing code that changes the DOM on page load [closed]

I am in the process of writing tests for my JS code with CasperJS and Mocha. I have a function that changes the DOM and gets run on page load (through jQuery's ...
1
vote
0answers
169 views

Mocha + should.js, testing for node

I'm new to the world of BDD, but I'd like to get a grip of it as soon as possible. It's one of my first tests: Fluent.js ...
3
votes
1answer
780 views

Unit testing Backbone Model

I would like to hear other people's opinion on how I unit tested a functionality in a Backbone Model. As you see below, the code under test, upon being called to toggle, toggles its completed state ...
3
votes
1answer
1k views

Am I using Q the right way or is there a better way to do what I'm doing?

I'm using Q to flatten out some callbacks in my unit tests and return a promise to mocha (which knows to wait until the promise is resolved before running the next test). Originally I had this code: ...