In a jasmine-node mock method, why is ".and" undefined?

33 views Asked by At

I'm running jasmine-node 3.0.0. When I run the following spec, jasmine reports "TypeError: Cannot read properties of undefined (reading 'returnValue')". Why? Do spy objects in jasmine-node work differently than in jasmine core? If so, how do I configure the return value of a mock method?

describe("CRUD operations", function () {
    it("completes successfully", () => {
        const mockDao = jasmine.createSpyObj('ProductDao', ['shutdown']);
        mockDao.shutdown = jasmine.createSpy('shutdown').and.returnValue(1)
    });
});

(In this case, a workaround is mockDao.shutdown = () => 1, but I lose all the other functionality of jasmine spies).

1

There are 1 answers

0
Mike Woinoski On

From the jasmine-node page on npmjs.org:

This project is now in maintenance mode. This project is now in maintenance mode. It is recommended to use the jasmine or jasmine-npm package whenever possible....Version 1.3.1 of Jasmine is currently included with node-jasmine

Jasmine 1.3.1 is very old. I think it's simply time to migrate from jasmine-node to jasmine.