-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
UUID "TypeError: Invalid schema configuration" #13241
Comments
Hmmm. This appears to only happen when testing with Jest. A workaround for an incompatibility between jest and uuid is tricking mongoose into screwing up the uuid import. According to uuidjs/uuid#451, This should work with uuid 9.0.0 and jest 29.4.0, but i'm getting no love on this. Any ideas? |
@jmbldwn can you please create a sample project that demonstrates this issue? We'd need more info, like Jest version, configs, etc. in order to repro this. We would also strongly recommend using any testing framework other than Jest. |
I actually solved this with a crafty Jest mock. See my answer in https://stackoverflow.com/questions/73203367/jest-syntaxerror-unexpected-token-export-with-uuid-library/75924883#75924883 I agree on Jest; it's a pain but we're somewhat heavily invested in it. Any suggestions that would be an easy conversion? |
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days |
@jmbldwn without a closer look at your code, hard to say what would be an easy conversion. We make heavy use of Mocha and have for almost a decade now, that would be my recommendation, but the conversion may or may not be easy depending on how much Jest-specific stuff your codebase uses. |
Prerequisites
Mongoose version
7.0.3
Node.js version
16.19.1
MongoDB server version
4.2.0
Typescript version (if applicable)
No response
Description
Encountering what appears to be a bug in the UUID type. I have a single field I'm adding via a plugin and it looks like the schema merging is getting confused. The error message is pretty explanatory:
I have no idea why the type is coming across as NIL. I've stepped through the code quite a bit and it looks like maybe the type definition for UUID is just wrong?
Steps to Reproduce
Define a schema type UUID and add it to an existing schema:
Expected Behavior
No error.
The text was updated successfully, but these errors were encountered: