openapi-nodegen-mem-mongo-loader

Helper class to load mongo db memory and then mongoose with 2 functions setup and stop - for unit testing purposes

Usage no npm install needed!

<script type="module">
  import openapiNodegenMemMongoLoader from 'https://cdn.skypack.dev/openapi-nodegen-mem-mongo-loader';
</script>

README

License | Dependencies | Codecov Coverage | Build Status

openapi-nodegen-mem-mongo-loader

Table of Contents generated with DocToc

A simple helper, setup helper and stop helper.

Handy for usage in jest tests, beforeAll and afterAll... but also/mainly.. I didn't want to write tests for this in my APIs or ignore in APIs jest config files.

Perquisites

It assumes you use mongoose, should be installed in your API. It is marked as a peer dep in this package.json file.

It does not assume you install mongodb-memory-server so installed as a dependency to this package.

Example

import OpenapiNodegenMemMongoLoader from 'openapi-nodegen-mem-mongo-loader';
describe('registerEmailPost domain', () => {

  beforeAll(async () => {
    await OpenapiNodegenMemMongoLoader.setup();
  });

  afterAll(async () => {
    await OpenapiNodegenMemMongoLoader.teardown();
  });
  // add some tests
})

Contribution

Pull requests welcomed as always.