joshwiens / nestjs-mongoose

NestJS / Mongoose Example
http://nestjs.com/
Apache License 2.0
47 stars 8 forks source link

Timeout - async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL #14

Closed alsoicode closed 6 years ago

alsoicode commented 6 years ago

Hello,

I'm just getting started with Nest and wanted to write some e2e tests against my controllers. I found your repo, and am getting an error when running the tests:

C:\Users\Brandon\Downloads\nestjs-mongoose-master>npm run test

> nest-typescript-starter@0.0.1 test C:\Users\Brandon\Downloads\nestjs-mongoose-master
> cross-env NODE_ENV=test jest --runInBand  --forceExit

 PASS  src\shared\exceptions\http-exceptions.spec.ts
 FAIL  src\app\hero\heros.spec.ts (22.173s)
  ● Module: HerosModule › HerosService › should find Heros0 by ObjectId

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

      at node_modules/jest-jasmine2/build/queue_runner.js:64:21
      at ontimeout (timers.js:475:11)
      at tryOnTimeout (timers.js:310:5)
      at Timer.listOnTimeout (timers.js:270:5)

 PASS  src\shared\environments.spec.ts

Test Suites: 1 failed, 2 passed, 3 total
Tests:       1 failed, 13 passed, 14 total
Snapshots:   0 total
Time:        24.576s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nest-typescript-starter@0.0.1 test: `cross-env NODE_ENV=test jest --runInBand  --forceExit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nest-typescript-starter@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Brandon\AppData\Roaming\npm-cache\_logs\2017-12-21T19_36_58_132Z-debug.log

When I just try to open a connection to the database:

import { Mockgoose } from 'mockgoose';
import { Mongoose } from 'mongoose';
import { Test } from '@nestjs/testing';

const mongoose = new Mongoose();
const mockgoose = new Mockgoose(mongoose);
const database = null;

beforeAll(async () => {
  await mockgoose.prepareStorage();
  this.database.connect('mongodb://localhost/test');
  return this.database;
}, 20000);

afterAll(async () => {
  await mockgoose.helper.reset();
  this.database.disconnect();
});

describe('Module: UnsubscribesModule', () => {
  it('should create a mockgoose database', async () => {
    expect(1).toEqual(1);
  });
});

I get a similar timeout error. I can confirm MongoDB is running as a service on my computer and works as expected when hitting the API endpoints directly through my application code.

Any ideas on what might be wrong?

Thanks, Brandon

alsoicode commented 6 years ago

Looks like this was the culprit for me: https://github.com/winfinit/mongodb-download/pull/27

I manually updated the URL in node_modules/mongodb-download/built/mongodb-download.js, line 13 for now.