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();
});
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!