Skip to content

Commit

Permalink
style(README): add note about what package.json is used
Browse files Browse the repository at this point in the history
- add an additional note about what package.json is used by default
- add example on how to change the package.json used
  • Loading branch information
hasezoey committed Sep 13, 2020
1 parent 22d765d commit 88119d4
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,34 @@ Works perfectly [with Travis CI](https://github.com/nodkz/graphql-compose-mongoo
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**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)
- [CI](#ci)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)
- [Maintainers](#maintainers)
- [MongoDB In-Memory Server](#mongodb-in-memory-server)
- [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)
- [CI](#ci)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)
- [Maintainers](#maintainers)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -294,6 +295,19 @@ Environment variables have higher priority than contents of package.json.
}
```

By default it uses the nearest (upwards) `package.json` to `process.cwd()`.
To change this:

```ts
import { findPackageJson } from "mongodb-memory-server-core/lib/util/resolve-config";

findPackageJson('/custom/path');

// OR

process.chdir('/custom/path'); // not recommended
```

### Simple test with MongoClient

Take a look at this [test file](https://github.com/nodkz/mongodb-memory-server/blob/master/packages/mongodb-memory-server-core/src/__tests__/singleDB-test.ts).
Expand Down

0 comments on commit 88119d4

Please sign in to comment.