2012-05-06 36 views
4

我想用VowsVows-BDD開始。不幸的是,回調讓我沮喪。如何用Vows和Node.js解決「回調未被觸發」

在下面的非常簡單的例子中,如何解決這個錯誤?

** Inside the first context 
** Creating Person with name Nick 

✗ Errored » callback not fired 
     in Create a Person via JavaScript: When a person has a name, 
     in Creating a Person 
     in undefined✗ Errored » 1 errored 1 dropped 
vows_bdd = require "vows-bdd" 
assert = require "assert" 


class Person 
    constructor: (@name) -> 
    console.log "** Creating Person with name #{@name}" 

    greeting: -> 
    "Hello, #{@name}" 


vows_bdd 
    .Feature("Creating a Person") 
    .scenario("Create a Person via JavaScript") 

    .when "a person has a name", -> 
     console.log "** Inside the first context" 
     new Person "Nick" 

    .then "the person can be greeted", (person) -> 
     console.log "person is a #{typeof person} = [#{person}]" 
     assert.equal person.greeting(), "Hello, Nick" 

    .complete() 
    .finish(module) 

回答

2

我知道這個職位是舊的,但因爲這是第一個結果,當有人搜索這個錯誤,我張貼我的答案。

我發現這篇文章有幫助,當處理錯誤。 http://birkett.no/blog/2013/05/01/vows-errored-callback-not-fired/

在我的代碼錯誤是由於其中一個主題發生異常。誓言並不打印實際的錯誤,因爲它很難理解確切的問題。

+0

不幸的是,該鏈接似乎已經死了,但仍然+1回答舊帖子:) –

+0

@RohanJ,由於鏈接不再起作用,你可以發佈它解釋的解決方案嗎? – nickh

+0

@nickh對不起,這是很久以前,因爲我沒有做過誓言,所以我不記得確切的解決方案。但我認爲其中一個主題正在拋出異常,因爲發生這種錯誤。我應該更清楚地記錄它,對此抱歉。 – RohanJ