question-mark
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.

Need some clarification

See original GitHub issue

Hi @alonronin,

Mockingoose looks great! Thanks for creating this project.

I am having trouble using Mockingoose + Jest in my project, but I am sure its due to my lack of knowledge and I am hoping you can provide some clarification.

I am trying to test a wrapper function but I keep getting a timeout in jest.

// userCreate.js
import { User } from '../models'

const createUser = user => {
  const doc = new User(user)
  return doc.save();
}

export default createUser;
// userCreate.test.js
import mockingoose from 'mockingoose';
import createUser from './createUser';

describe('test create user api', () => {
  it('should create user', async () => {
    mockingoose.User.toReturn({ _id: '507f191e810c19729de860ea' }, 'save');
    return createUser({ first_name: 'Calvin', last_name: 'Chan' })
      .then(result => {
        console.log(result); 
        expect(true).toBe(true);
      });
  });
});
// console
$> jest
 FAIL  src/users/createUser.test.js (7.675s)
  ● test create user api › should create user

    Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.

I am expecting the test to pass but receiving a timeout instead. It looks like the promise is never resolved in createUser.js. Any guidance will be greatly appreciated.

Thanks in advance for your help!

Calvin

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
radTuticommented, Jan 31, 2018

i have the same problem too and i find that using mockingoose@2.4.0 works fine but newer releases result in the timeout

0reactions
alonronincommented, Feb 8, 2018

@calvintychan can you share with me a sample project so I can test it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

I need some clarification | English examples in context - Ludwig
High quality example sentences with “I need some clarification” in context from reliable sources - Ludwig is the linguistic search engine that helps...
Read more >
I need some clarification on the matter. or I need ... - TextRanch
You want me to complete the job, I need some clarification. Given that the scope of the 'health check' exercise is not yet...
Read more >
How to Ask for Clarification - VOA Learning English
After you express your lack of understanding, the next step is to ask the person to clarify what they have said. Here are...
Read more >
I need some clarification on some points ! : r/grammar - Reddit
Hey guys, I have confusions about several points : is it correct to say : ''I wish I could have'' to express my...
Read more >
20 Email Expressions to Ask for Clarification - Tannia Suarez
Could you give me some more details about...? Correct me if I'm wrong… As no doubt you are aware… Let me know if...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found