BDD and TDD for node.js?

前端 未结 11 1288
北恋
北恋 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 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)
    

提交回复
热议问题