TypeError: <function> is not a function (Only interacting with Mongoose) #3565
Labels
invalid
not something we need to work on, such as a non-reproducing issue or an external root cause
type: question
support question
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend avoiding the use of globally installed Mocha.Description
I'm using mocha to test some CRUD functions for my Mongoose models. One is System, then two very similar models for an I[input]Sector and an O[utput]Sector. I can assure that all the models exist as do the functions I'm calling in the test.
What is failing is the following test (note that in a top-level test file I'm connecting to the database and I drop collections between each test):
(Feel free to skip the next two blocks of code because they are mostly for context)
For more context, here is the function it is calling in the model:
And for more context, here is the function defined in one of the sector models (they're pretty incredibly similar to each other):
As mentioned the actual implementation isn't incredibly important and may be difficult to understand without going through the rest of the code; however, I've already tested it at a higher level using the HTTP requests these functions are called from. What is strange though is that when I try to run this in Mocha, it throws this error:
Steps to Reproduce
before()
hook(I'm honestly not sure how to simplify the case any more than that without starting a whole new project)
Expected behavior: [What you expect to happen]
Runs the function as referenced and throws errors only within the scope of the test.
Actual behavior: [What actually happens]
Throws an invalid type answer --not finding a function that was defined.
Reproduces how often: [What percentage of the time does it reproduce?]
100%
Versions
I'm not even far enough into development to have integrated things like webpack, transpilers, gulp, etc. This is just using Mongoose (with Bluebird for the promise lib) and raw js.
Additional Information
If you could even give me some direction as to how to debug this, I can try looking into it myself.
Here's a link to my repo at the commit where I uploaded the issue-causing test
I'm hoping I'm just having a moment here and it's not a huge deal, so I'll be continuing to look through this. I'll close the issue if I find anything unrelated to Mocha. I chose to open the issue instead of going to StackOverflow because I noticed there were a couple other people that were experiencing similar issues, but always with 3rd-party apps in between. This strikes me as a simlar case using only Mocha, Mongoose, and Js.
The text was updated successfully, but these errors were encountered: