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

betaUser default #14

Open
vjandrei opened this issue Dec 10, 2019 · 7 comments
Open

betaUser default #14

vjandrei opened this issue Dec 10, 2019 · 7 comments

Comments

@vjandrei
Copy link

vjandrei commented Dec 10, 2019

I have on the start user.js

betaUser: { type: Boolean, default: false },

like that but the test is not passing it? betaUser should default to false (11ms)

Here is the full schema

const mongoose = require('mongoose') const userSchema = new mongoose.Schema({ firstName: { type: String, required: true }, lastName: { type: String, required: true }, email: { type: String, required: true, unique: true }, betaUser: { type: Boolean, default: false }, birthDate: Date, address: { other: Boolean, street: String, houseNumber: Number, zip: Number, city: String, State: String }, pets: [{type: String}] }) module.exports = mongoose.model('user', userSchema)

@sandeep206
Copy link

I am also having the same issue. And I see a very strange error in the console. MongoError: pool is draining, new operations prohibited

@chrisueda
Copy link

chrisueda commented Mar 24, 2020

It seems like passing the options object like this:

  return mongoose.connect(url, {
    poolSize: 100,
    useNewUrlParser: true,
    useUnifiedTopology: true
  });
};

Solved the pool is draining issue for me.

@mkelley33
Copy link

@chrisueda your solution also made the test betaUser should default to false pass for me, but should have correct fields is still failing.

@thebestfella
Copy link

for me the code @chrisueda provided only fix the pool is draining issue, but betauser and correct fields still both are failing...

@joeyfurness
Copy link

in testconfig.js, I had to move mongoose.disconnect() from afterEach to afterAll . I think mongodb just didn't like the rapid connecting and disconnecting ? I"m not sure if this is a fix, but it's definitely a hack that worked.

@AbdouTanta
Copy link

@josephmwells your solution worked for me

@Anksus
Copy link

Anksus commented Oct 20, 2020

thanks @josephmwells it works now

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

8 participants