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

All tests timeout on fresh API generation on Windows 10. #106

Open
misleadingTitle opened this issue Sep 13, 2017 · 11 comments
Open

All tests timeout on fresh API generation on Windows 10. #106

misleadingTitle opened this issue Sep 13, 2017 · 11 comments

Comments

@misleadingTitle
Copy link

On a fresh generation of the REST API on Windows 10 all the tests timeout with errors similar to this:

FAIL  src\services\response\index.test.js (16.109s)
  ● success › responds with passed object and status 200

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

      at Timeout._onTimeout (node_modules\jest-jasmine2\vendor\jasmine-2.5.2.js:1979:23)
      at ontimeout (timers.js:365:14)
      at tryOnTimeout (timers.js:237:5)
      at Timer.listOnTimeout (timers.js:207:5)

I've tried to get the exact packages version listed in the npm package (instead of the most recent ones) but nothing changed. I've also tried on differend windows machines (both Windows 10 and 7) without success. Node and mongo are updated to latest versions.

I haven't found anyone else with this issue so far and it seems strange. What can be the problem?

It might be partially mockgoose related since removing the mock and using a real database makes the firsts tests pass but then, after an handful of passed tests, all the following cases timeout.

Any idea?

@hboylan
Copy link

hboylan commented Nov 6, 2017

I'm having the same issue on Windows 8.1

Also tried running jest with the -i or --runInBand flag (as per this Jest issue), which does not work.

@maustand maustand added the bug label Nov 7, 2017
@maustand
Copy link
Collaborator

maustand commented Nov 7, 2017

Hi
I am working on ubuntu 16.4 and my co workers on mac and it works perfect.
Did you update your dependencies ?

There is a problem if you update mockgoose to the lastest version, it would not work.

Could you provide us more details ?

Regards

@hboylan
Copy link

hboylan commented Nov 7, 2017

@maustand Thanks for the reply.

Using the same code base on Mac last night, I was able to run all of the generator-rest tests in ~8s. Still having the same issue on Windows today.

The core issue appears to be an ongoing bug with Jest's parallelization on Windows.

(Adding --runInBand doesn't fix the problem for me).

@hboylan
Copy link

hboylan commented Nov 7, 2017

So commenting out mockgoose in test/setup.js allows jest -i to run properly.

Neither v6.0.8 (generator default) or v7.3.3 (latest release) of mockgoose are working.
Do you know a version that does?

@maustand
Copy link
Collaborator

maustand commented Nov 7, 2017

@hboylan Sadly i dont have windows and i could not reproduce this bug in my pc.
Anyway lets see if the jest team can fix and i will update the dependencies again.

Currently i working on ubuntu 16.4,
nodejs v6.11.4
jest-cl": "^20.0.4",
mockgoose: "^6.0.8",

So It works perfect, but i tried to update to a newer version of mockgoose and it does not work, even if you update jest to v21.0.0 or a newer version, it does not work too..

If you need, i could send you my configuration or just check this package.json

Regards

@hboylan
Copy link

hboylan commented Nov 7, 2017

Thanks for looking into it. Windows always has the best Node bugs. ;)

For now, running Jest in serial without Mockgoose is a viable solution. It didn't work for me, but I noticed the Mockgoose example wraps Mongoose with prepareStorage().

I can help clean dependencies and/or deprecation warnings if you like.

@maustand
Copy link
Collaborator

maustand commented Nov 7, 2017 via email

@hboylan
Copy link

hboylan commented Nov 7, 2017

Hey, I figured out why Mockgoose isn't working!

✖️

import mockgoose from 'mockgoose'
import mongoose from 'mongoose'

beforeAll(async () => {
  await mockgoose(mongoose)
  mongoose.connect(mongo.uri)
})

✔️

import {Mockgoose} from 'mockgoose'
import mongoose from 'mongoose'

const mockgoose = new Mockgoose(mongoose)

beforeAll(async () => {
  await mockgoose.prepareStorage()
  await mongoose.connect(mongo.uri, mongo.opts)
})

@misleadingTitle This fixes the timeout issue for me.

hboylan added a commit to hboylan/rest that referenced this issue Nov 7, 2017
hboylan added a commit to hboylan/rest that referenced this issue Nov 8, 2017
@misleadingTitle
Copy link
Author

Thanks @hboylan, this fixed it for me too!

@marcoshuck
Copy link

marcoshuck commented Jan 12, 2018

@hboylan hey, I have been trying your fix but I can't make it work. This is what I got when I try npm test

Test suite failed to run
TypeError: _mockgoose.Mockgoose is not a constructor

Any idea why?

@hboylan
Copy link

hboylan commented Jan 13, 2018

@marcoshuck I forget the specific reason for that error, but I think it had something to do with the mockgoose version being used. For instance, maybe updating to the latest version of it breaks that syntax...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants