Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property '$handleCallbackError' of undefined #51

Open
altairo2087 opened this issue Oct 17, 2019 · 0 comments
Open

Cannot read property '$handleCallbackError' of undefined #51

altairo2087 opened this issue Oct 17, 2019 · 0 comments

Comments

@altairo2087
Copy link

Dependencies:

"mongoose": "5.7.3",
"sinon": "7.5.0",
"sinon-mongoose": "2.3.0",

Sample app code

const query = Car.find();
query.limit(10);
const rows = await query.lean();

Test code:

sinon.mock(Car)
      .expects('find')
      .chain('limit')
      .withArgs(10)
      .chain('lean')
      .resolves([]);

Error

      TypeError: Cannot read property '$handleCallbackError' of undefined
          at Query.exec (...\node_modules\mongoose\lib\query.js:4305:25)
          at Query.Object.<anonymous>.Query.then (...\node_modules\mongoose\lib\query.js:4367:15)
          at then (...\server\handlers\cars\list.js:51:37)
          at Object.list (...\server\handlers\cars\list.test.js:40:11)
          at Object.asyncJestTest (...\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:102:37)
          at ...\node_modules\jest-jasmine2\build\queueRunner.js:43:12
          at new Promise (<anonymous>)
          at mapper (...\node_modules\jest-jasmine2\build\queueRunner.js:26:19)
          at ...\node_modules\jest-jasmine2\build\queueRunner.js:73:41
          at processTicksAndRejections (internal/process/task_queues.js:93:5)

If a remove .chain('limit').withArgs(10) there is no error

sinon.mock(Car)
      .expects('find')
      .chain('lean')
      .resolves([]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant