Comments (7)
Hi @janek-bieser,
I have never tried to use populate with mockgoose.
I will look into this.
Thanks
from mockgoose.
We're having the same issue.
from mockgoose.
I may have tracked down the issue. When items are fetched in Mockgoose it uses _.clone to clone the item. However, nested objects don't get cloned and get assigned by reference. So when the populate goes in and updates the populated values, it's doing it on the references not the cloned values.
There needs to be some sort of recursive cloning since there is some custom logic re ObjectIds.
Edit: I think I have a fix for this issue, i'll test it some more and try to get it up tonight.
from mockgoose.
HI - any updates on the open pull request? I wanted to get the populate() function working on my unit tests and would be great if this solved the populate issue.
from mockgoose.
@yads so it looks like your fix works if you don't pass any select fields to the populate, but if you do it runs into the same issue .. e.g. .populate('createdBy', {fname:1, lname:1});
from mockgoose.
It would be really really cool to have this fixed!
from mockgoose.
pull request was merged and new 2.0.2 version in now on npm, thank you for your change.
from mockgoose.
Related Issues (20)
- mockgoose.reset() removes previously added data, mongoose.unmock() does nothing HOT 3
- gruntfile missing? HOT 4
- mockgoose will eat the error message of `Error: Cannot find module '../test/util.js' from `require()` in `mocha 2.4.5` HOT 1
- Error with ava: TypeError: callback is not a function HOT 26
- Uncaught TypeError: Object #<Object> has no method 'spawnSync' HOT 3
- Error parsing command line: unrecognised option '--fork' HOT 5
- Upgrading from v5 to v6 breaks create function HOT 2
- EventEmitter leak on mongoose disconnection HOT 2
- mongod process does not stop in a dockerized jenkins container HOT 2
- mockgoose-mongoose4 problem with $or HOT 15
- mockgoose(mongoose).then is not a function HOT 2
- Error running mocha test HOT 10
- unmock not working when using createConnection HOT 1
- Project migrated HOT 5
- Mockgoose can not install due to issue with mongodb_prebuilt HOT 3
- Gives MongoError if mongod is not running locally HOT 1
- Mockgoose.reset throws error with createConnection HOT 3
- Compound index not working HOT 2
- Subdocuments not returned when using projection with Mockgoose HOT 1
- Raspberry pi support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockgoose.