没有来自jasmine-node的输出 [英] No output from jasmine-node

查看:81
本文介绍了没有来自jasmine-node的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript,Node.js和jasmine的新手。我正在尝试从节点工匠书,FilesizeWatcher这本书中进行测试。我创建了package.json文件并运行npm install,从而在本地安装jasmine-node到项目中。当我在spec文件上运行jasmine-node时,我只看到来自console.log的输出,但是没有来自jasmine的输出。我可以从调用jasmine的console.log语句中看到(例如expect(err).toBe(Path不以斜杠开头);),但是没有输出。

I'm new to JavaScript, Node.js and jasmine. I'm trying to run a test from the book "The Node Craftsman Book", FilesizeWatcher. I've created the package.json file and run "npm install", thus installing jasmine-node locally to the project. When I run jasmine-node on the spec file I see only output from console.log but nothing from jasmine. I can see from console.log statements that calls to jasmine (e.g. expect(err).toBe("Path does not start with a slash");) are made, but there is no output.

我应该从哪里开始发现错误?

Any idea of where i should start to find an error?

推荐答案

我知道你指的是什么代码。问题是

I know what code you are referring to. The problem is

watcher.on('grew', function(gain) { 
 expect(gain).toBe(5);
 done();
});

替换为:

watcher.callbacks['grew'] = function(gain) { 
 expect(gain).toBe(5);
 done();
}

问题的核心似乎是测试编写为运行不同的代码。从纯JS的角度来看, watcher 对象在key上没有,因此,只需阅读代码,我不希望它工作。我也是Node的新手,一开始,我只是假设它会起作用。我认为那里的教训是:JS是JS,没有任何节点可以改变它。我在一本名为Eloquent Javascript的书中找到了更好的介绍。祝你好运!

The core of the problem seems to be that the test is written to run on different code. From a pure JS point of view, watcher object does not have the on "key" and therefore, by simply reading the code, I would not expect it to work. I am new to Node too so, at first, I simply assumed that it would work. I think the lesson there is: JS is JS and nothing node does with it changes that. I found a much better introduction in a book called "Eloquent Javascript". Good luck!

这篇关于没有来自jasmine-node的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆