BDD and TDD for node.js?

node.jsRspecTddCucumberBdd

node.js Problem Overview


What is used for BDD and TDD with node.js?

I'm used to use Cucumber + RSpec. What's a good combo for node.js?

thanks

node.js Solutions


Solution 1 - node.js

Update

Mocha gets my vote now!


You could have a look at the testing modules section from the node.js modules page. For example Vows is a pretty popular BDD framework.

> Vows is a behavior driven development framework for Node.js.

Solution 2 - node.js

Check out mocha - (github)

Also mocha-cakes, my attempt for Cucumber syntax on mocha.

Solution 3 - node.js

If you are used to rspec, Jasmine is pretty nice. I've not used it on Node.js, but I have used it for testing a backbone app. It's syntax is very similar to rspec. Taken from the site above:

describe("Jasmine", function() {
  it("makes testing JavaScript awesome!", function() {
    expect(yourCode).toBeLotsBetter();
  });
});

It's listed in the link provided by Alfred above, but since folks listed Vows as an example, I figured I'd give Jasmine a bump, especially since it's syntactically similar to rspec ;)

Solution 4 - node.js

There is the 'Vows' project for BDD on Node http://vowsjs.org, looks pretty nice. It's a bit different from RSpec/Cucumber, but it's pretty fun

Solution 5 - node.js

Maybe a little later, but what you're looking for is Kyuri: https://github.com/nodejitsu/kyuri

"kyuri is a node.js Cucumber implementation with a few extra asynchronous keywords. it supports 160+ languages and exports to VowsJS stubs"

Also, nodejitsu seems to have built a web app for managing a project Kyuri feature specs in a collaborative way, it's named "prenup", I would give it a look.

Solution 6 - node.js

You could also try yadda. It plugs into other test libraries including mocha, jasmine, casper & webdriver, but also lets you write proper feature files instead of merely annotating you tests in situ. A typical test might look like...

var Yadda = require('yadda');
Yadda.plugins.mocha();

feature('./features/bottles.feature', function(feature) {

   var library = require('./bottles-library');
   var yadda = new Yadda.Yadda(library);

   scenarios(feature.scenarios, function(scenario, done) {
      yadda.yadda(scenario.steps, done);
   });
});

And the feature file...

Feature: Mocha Asynchronous Example

Scenario: A bottle falls from the wall

Given 100 green bottles are standing on the wall
when 1 green bottle accidentally falls
then there are 99 green bottles standing on the wall

And output...

Mocha Asynchronous Example
✓ A bottle falls from the wall 

1 passing (12ms)

Solution 7 - node.js

Check out Buster.JS. Created by Christian Johansen, who literally wrote the book on javascript testing.

Buster supports both TDD and BDD. It does browser testing with browser automation (think JsTestDriver), QUnit style static HTML page testing, testing in headless browsers (PhantomJS, jsdom), and more.

Solution 8 - node.js

Package a (bdd and mocking) https://npmjs.org/package/a

Very compact syntax, context separated from acts, chainable acts. Easy Cmd line runner that searches recursively.

Solution 9 - node.js

Unit tests: Mocha is great for unit tests.

BDD tests If you want a BDD test framework for Node.js then I'd recommend the Cucumber package.

Solution 10 - node.js

I was going through the same concern last month .

For BDD :

Though Mocha itself provides BDD style by their describe and it statements.

For styles like cucumber , you can try :

  • mocha-cakes
  • mocha-gherkin
  • cucumber.js
  • kyuri
  • mocha-cucumber

They all have their own styles. I am sorry I can not provide working snippets now , let me know @Donald which one you select. Would like to know your insight.

Solution 11 - node.js

I too was looking for a good Gherkin implementation, found mocha-cakes/mocha-cakes-2 which were nice but not very full featured. So I build my own with mocha as the base, which has parity with the gherkin language including Scenario Outlines. It also makes it easy to reference the data in your test. Its different to cucumber.js as its all inline not separate files. You can find the project here:

livedoc-mocha

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondonaldView Question on Stackoverflow
Solution 1 - node.jsAlfredView Answer on Stackoverflow
Solution 2 - node.jsQuang VanView Answer on Stackoverflow
Solution 3 - node.jsCraig MonsonView Answer on Stackoverflow
Solution 4 - node.jsNikolayView Answer on Stackoverflow
Solution 5 - node.jsBenjaView Answer on Stackoverflow
Solution 6 - node.jscressie176View Answer on Stackoverflow
Solution 7 - node.jsTaurenView Answer on Stackoverflow
Solution 8 - node.jsLars-Erik RoaldView Answer on Stackoverflow
Solution 9 - node.jsThomas BrattView Answer on Stackoverflow
Solution 10 - node.jsuser3251882View Answer on Stackoverflow
Solution 11 - node.jsdnpView Answer on Stackoverflow