sinonjs / sinon

Test spies, stubs and mocks for JavaScript.

Home Page:https://sinonjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to return value for node-cache

chungyau97 opened this issue · comments

Describe the bug
I'm not able to mock node-cache's get function to return a specific value

To Reproduce
Steps to reproduce the behavior:

Below are the functions in cacheService.js:
image

Below are the unit test in cacheService.test.js
image

Expected behavior
It should return "exampleData" instead of undefined

Screenshots of error
image

Context (please complete the following information):

  • Library version:
    "node-cache": "^5.1.2"
    "chai": "^4.3.7",
    "mocha": "^10.2.0",
    "nyc": "^15.1.0",
    "sinon": "^15.0.1"

We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question; please post it to StackOverflow and tag it with sinon, so the bigger community can help answer your questions.

If you feel that your topic is an issue with Sinon, please open a new ticket and follow the guidelines for reporting an issue.


This is a very nice and seemingly easily reproducible test case, so I would suspect that someone should be able to help you very quickly. There seems to always be someone subscribing to the sinon label on SO, so I think they should be able to help you out 👍

P.S. Feel free to post a comment here with link to the StackOverflow question+answer.