Skip to content

Mock populate when called directly #101

@pnts-se

Description

@pnts-se

Thank you for a very good library!

I'm able to mock populate() when called in a chain like so:

find()
      .sort({ createdAt: -1 })
      .limit(5)
      .populate("foreignKey");

I'm not able to mock populate() when called directly, e.g:

const doc = new MyModel({
      content: content,
      foreignKey: foreignKey
    });
await doc.save();
await doc.populate("foreignKey");

I get:
TypeError: Cannot read properties of null (reading 'populate')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions