No output from jasmine-node

a 夏天 提交于 2019-12-05 21:58:27

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

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

Replace with:

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

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!

I had the same issue and discovered that by adding the switch:

--captureExceptions

Mentioned by @Charminbear in the comments above, jasmine-node produced a list of errors in my scripts. Fixing these resolved the issue.

I managed to get this to work after realising a few errors on my part.

Firstly, I still had self.callbacks = {}; in my code. I removed this. Secondly, I was still using self.callbacks['error']('Path does not start with a slash');. I changed it to self.emit('error', 'Path does not start with a slash');

Problem solved (for me).

Ethan

I had the same issue, thanks @John Doherty's answer, I discovered my problem:

self.callbacks = {};
//...
FilesizeWatcher.prototype.on = function(eventType, callback) {
    this.callback[eventType] = callback;
};

It's a typo on this.callback, it should be this.callbacks:

FilesizeWatcher.prototype.on = function(eventType, callback) {
    this.callbacks[eventType] = callback;
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!