BDD and TDD for node.js?

前端 未结 11 1286
北恋
北恋 2021-01-29 20:37

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

相关标签:
11条回答
  • 2021-01-29 20:59

    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

    0 讨论(0)
  • 2021-01-29 21:02

    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.

    0 讨论(0)
  • 2021-01-29 21:08

    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

    0 讨论(0)
  • 2021-01-29 21:15

    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)
    
    0 讨论(0)
  • 2021-01-29 21:16

    Check out mocha - (github)

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

    0 讨论(0)
  • 2021-01-29 21:16

    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.

    0 讨论(0)
提交回复
热议问题