diff --git a/README.md b/README.md index 0c7b3b988..192025a8f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This package spins up an actual/real MongoDB server programmatically from node, for testing or mocking during development. By default it holds the data in memory. A fresh spun up `mongod` process takes about 7Mb of memory. The server will allow you to connect your favorite ODM or client library to the MongoDB server and run integration tests isolated from each other. -On install, this package downloads the latest MongoDB binaries and saves them to a cache folder. +On install, this [package downloads](#configuring-which-mongod-binary-to-use) the latest MongoDB binaries and saves them to a cache folder. On starting a new instance of the memory server, if the binary cannot be found, it will be auto-downloaded, thus the first run may take some time. All further runs will be fast, because they will use the downloaded binaries. @@ -20,6 +20,39 @@ Every `MongoMemoryServer` instance creates and starts a fresh MongoDB server on Works perfectly [with Travis CI](https://github.com/nodkz/graphql-compose-mongoose/commit/7a6ac2de747d14281f9965f418065e97a57cfb37) without additional `services` and `addons` options in `.travis.yml`. + + +**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* + +- [Installation](#installation) + - [Requirements](#requirements) + - [Known Incompatibilities](#known-incompatibilities) + - [mongodb-memory-server](#mongodb-memory-server) + - [mongodb-memory-server-global](#mongodb-memory-server-global) + - [mongodb-memory-server-core](#mongodb-memory-server-core) + - [Configuring which mongod binary to use](#configuring-which-mongod-binary-to-use) +- [Usage](#usage) + - [Simple server start](#simple-server-start) + - [Available options for MongoMemoryServer](#available-options-for-mongomemoryserver) + - [Replica Set start](#replica-set-start) + - [Available options for MongoMemoryReplSet](#available-options-for-mongomemoryreplset) + - [Options which can be set via ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables) + - [Options which can be set via package.json's `config` section](#options-which-can-be-set-via-packagejsons-config-section) + - [Simple test with MongoClient](#simple-test-with-mongoclient) + - [Provide connection string to mongoose](#provide-connection-string-to-mongoose) + - [Several mongoose connections simultaneously](#several-mongoose-connections-simultaneously) + - [Simple Mocha/Chai test example](#simple-mochachai-test-example) + - [Simple Jest test example](#simple-jest-test-example) + - [AVA test runner](#ava-test-runner) + - [Docker Alpine](#docker-alpine) + - [Enable Debug Mode](#enable-debug-mode) +- [Travis](#travis) +- [Credits](#credits) +- [License](#license) +- [Maintainers](#maintainers) + + + ## Installation This tool provides three packages for different purposes: @@ -46,7 +79,7 @@ And one of those: - ArchLinux & Alpine do not have an offical mongodb build - ArchLinux(Docker) does not have an `/etc/os-release` file by default -### `mongodb-memory-server` +### mongodb-memory-server Auto-downloads the latest `mongod` binary on npm install to: `node_modules/.cache/mongodb-binaries`. @@ -56,7 +89,7 @@ yarn add mongodb-memory-server --dev npm install mongodb-memory-server --save-dev ``` -### `mongodb-memory-server-global` +### mongodb-memory-server-global Auto-downloads the latest `mongod` binary on npm install to: `%HOME%/.cache/mongodb-binaries` / `~/.cache/mongodb-binaries`. @@ -66,7 +99,7 @@ yarn add mongodb-memory-server-global --dev npm install mongodb-memory-server-global --save-dev ``` -### `mongodb-memory-server-core` +### mongodb-memory-server-core Does NOT auto-download `mongod` on npm install. @@ -78,6 +111,14 @@ npm install mongodb-memory-server-core --save-dev _Note: the package does try to download `mongod` upon server start if it cannot find the binary._ +### Configuring which mongod binary to use +The default behaviour is that the latest version for your OS will be downloaded. By setting [ENVIRONMENT variables](#options-which-can-be-set-via-environment-variables) you are able to specify which version and binary will be downloaded: + +```bash +export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz +export MONGOMS_VERSION=4.2.8 +``` + ## Usage ### Simple server start diff --git a/package.json b/package.json index 77db2befe..b75276d69 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "jest": "jest --env node", "build": "tsc --build tsconfig.build.json", "release": "lerna publish --conventional-commits", + "readme:toc": "npx doctoc ./README.md", "postinstall": "yarn build" } }