簡體   English   中英

如何使用Vows和Node.js解決“未觸發回調”

[英]How to solve “callback not fired” with Vows and Node.js

我正在嘗試開始使用VowsVows-BDD 不幸的是,這些回調使我震驚。

在以下非常簡單的示例中,如何解決此錯誤?

** 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)

我知道這篇文章很舊,但是因為這是有人搜索此錯誤的第一個結果,所以我發布了我的答案。

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

在我的代碼中,錯誤是由於其中一個主題發生異常而引起的。 Vows不會打印實際錯誤,因為它很難理解確切的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM