首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用Vows和Node.js解决“回调未触发”问题

如何用Vows和Node.js解决“回调未触发”问题
EN

Stack Overflow用户
提问于 2012-05-07 04:27:59
回答 1查看 801关注 0票数 4

我正在尝试开始使用VowsVows-BDD。不幸的是,回调把我给绊倒了。

在下面这个非常简单的例子中,如何修复这个错误?

代码语言:javascript
复制
** 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
代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2013-07-30 14:09:15

我知道这篇文章很旧,但由于这是有人搜索这个错误时的第一个结果,所以我发布了我的答案。

在处理错误时,我发现这篇文章很有帮助。http://birkett.no/blog/2013/05/01/vows-errored-callback-not-fired/

在我的代码中,错误是由其中一个主题中发生的异常引起的。Vows不打印实际错误,因为它很难理解确切的问题。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10474002

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档