mikhail-angelov / mongo-unit

MIT License
72 stars 39 forks source link

mongoUnit.start returns undefined #32

Closed legik-9i closed 4 years ago

legik-9i commented 4 years ago

Hello.

I try to use this package to unit test with jest. There are no any mongodb driver on my PC.

I have this code

import mongoUnit from 'mongo-unit';

describe('CRUD Contract', () => {
  it('create', async () => {
    const dbUrl = await mongoUnit.start();
    console.log(dbUrl);
    expect(1 + 1).toBe(2);
    mongoUnit.stop();
  },
  10000);
});

Output is:

 PASS  src/tests/modules/contract/index.test.js
  CRUD Contract
    ✓ create (2439ms)

  console.log src/tests/modules/contract/index.test.js:8
    undefined

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        4.803s, estimated 6s

But, as you see, dbUrl is undefined. Why? Is it a bug from here?

beatthat commented 4 years ago

I came across this and fixed it in this PR:

https://github.com/mikhail-angelov/mongo-unit/pull/33

mikhail-angelov commented 4 years ago

this PR is merged v 2.0.0 so it should be fixed