Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

more detailed example tests would be great

See original GitHub issue

I’m trying to use this lib in my project but can’t wrap my head around how exactly to integrate it. I’m using migrations so I have the auto-generated models/index.js that is importing all Models.

Was trying to use $overrideImport but don’t know how …

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

dalexander-trccommented, Apr 27, 2018

I also found this somewhat confusing to get started, as all of my models are similarly accessed through a models/index.js require statement. What I did was instead of overriding individual models as the documentation seems to suggest, I overwrote my require statement with a collection and proxyquire.

In my-module.js

var models = require("../common/models");

In my-test.js

var mockModels = {
    "User": UserMock = DBConnectionMock.define('user', {
        'name': 'Bob'
    "Project": ProjectMock= DBConnectionMock.define('project', {
        'name': '2018 Budget'
var proxyquire = require('proxyquire');
var MyModule = proxyquire('../common/my-module', {
    '../common/models': mockModels

I did this so that my-module.js can continue to reference models.User.blah and models.Project.blah.

kvr2277commented, Mar 23, 2019

See if this article helps - Sequelize mocking with Jest and Node”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test Types & Their Strategies | Academic Success Center
MULTIPLE CHOICE TESTS​​ Because they're designed to make sure you know the information, these tests often include more than just recognition, vocabulary, and ......
Read more >
Tips for Writing Better Test Questions | REAL Examples
REAL examples & screenshots to help you write better test questions. Writing effective test questions can be hard, but these steps make it ......
Read more >
Improving Your Test Questions - CITL
Essay exams require more thorough student preparation and study time than objective ... Constant use of essay tests may encourage the knowledgeable but...
Read more >
Constructing tests - Center for Teaching and Learning
Designing tests is an important part of assessing students understanding of course content and their level of competency in applying what they are...
Read more >
Writing Good Multiple Choice Test Questions
Multiple choice test items are less susceptible to guessing than true/false questions, making them a more reliable means of assessment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found