Skip to content

Commit a5b6aba

Browse files
committed
Merge branch 'beta'
2 parents c6c4404 + abdf77b commit a5b6aba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1163
-693
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
node-version: [14.x, 16.x, 18.x, 20.x, 22.x]
20+
node-version: [16.x, 18.x, 20.x, 22.x]
2121
steps:
2222
- uses: actions/checkout@v4
2323
if: github.event.inputs.git-ref == ''
@@ -52,7 +52,7 @@ jobs:
5252
env:
5353
CI: true
5454
- name: Send codecov.io stats
55-
if: matrix.node-version == '14.x'
55+
if: matrix.node-version == '16.x'
5656
uses: codecov/codecov-action@v4
5757
with:
5858
token: ${{ secrets.CODECOV_TOKEN }}
@@ -63,10 +63,10 @@ jobs:
6363
runs-on: ubuntu-latest
6464
steps:
6565
- uses: actions/checkout@v4
66-
- name: Use Node.js 18
66+
- name: Use Node.js 20
6767
uses: actions/setup-node@v4
6868
with:
69-
node-version: 18.x
69+
node-version: 20.x
7070
- name: Install node_modules
7171
run: yarn install
7272
- name: Build

CHANGELOG.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,105 @@
1+
## [10.0.0-beta.5](https://github.com/typegoose/mongodb-memory-server/compare/v10.0.0-beta.4...v10.0.0-beta.5) (2024-07-18)
2+
3+
4+
### ⚠ BREAKING CHANGES
5+
6+
* **resolveConfig:** Default binary version is now "7.0.11"
7+
8+
### Features
9+
10+
* **resolveConfig:** update default binary version to 7.x ([9d569ac](https://github.com/typegoose/mongodb-memory-server/commit/9d569ac63e7f6bd729e0d98254226f4ed18acb0a))
11+
12+
## [10.0.0-beta.4](https://github.com/typegoose/mongodb-memory-server/compare/v10.0.0-beta.3...v10.0.0-beta.4) (2024-07-18)
13+
14+
15+
### Features
16+
17+
* **index:** also top-level export "DryMongoBinary" and all errors ([d11abaa](https://github.com/typegoose/mongodb-memory-server/commit/d11abaaa9e7207756bd6d599b2455e7d5761f638))
18+
19+
20+
### Dependencies
21+
22+
* **semver:** upgrade to version 7.6.3 ([100e571](https://github.com/typegoose/mongodb-memory-server/commit/100e57100c1c334c29a38ab8efaed0f7942e3235))
23+
24+
25+
### Dev-Dependencies
26+
27+
* **eslint-plugin-prettier:** upgrade to version 5.2.1 ([15990b9](https://github.com/typegoose/mongodb-memory-server/commit/15990b97549a6a8632bab303d4a10204d91d90fe))
28+
29+
## [10.0.0-beta.3](https://github.com/typegoose/mongodb-memory-server/compare/v10.0.0-beta.2...v10.0.0-beta.3) (2024-07-15)
30+
31+
32+
### Features
33+
34+
* **MongoMemoryServer:** allow setting if port generation is enabeld or not ([6c4daed](https://github.com/typegoose/mongodb-memory-server/commit/6c4daedf82ab86920037c5bb1dd2a15ba4031bbe)), closes [#816](https://github.com/typegoose/mongodb-memory-server/issues/816)
35+
36+
37+
### Style
38+
39+
* **MongoMemoryReplSet:** fix lint ([bd8941b](https://github.com/typegoose/mongodb-memory-server/commit/bd8941b331eec9f4317ef8456142db69917528a3))
40+
41+
42+
### Dependencies
43+
44+
* **https-proxy-agent:** upgrade to version 7.0.5 ([4d5be4d](https://github.com/typegoose/mongodb-memory-server/commit/4d5be4d5aa8330ab73dff8d0c1f5d0090b20e39b))
45+
46+
47+
### Dev-Dependencies
48+
49+
* **prettier:** upgrade to version 3.3.3 ([5aba25a](https://github.com/typegoose/mongodb-memory-server/commit/5aba25a865f08184b1db1f433c35f35242d91b55))
50+
* **rimraf:** upgrade to version 5.0.9 ([a6d706a](https://github.com/typegoose/mongodb-memory-server/commit/a6d706a75ab9560beb8c8053ddb7fabf42c453ca))
51+
* **ts-jest:** upgrade to version 29.2.2 ([839e432](https://github.com/typegoose/mongodb-memory-server/commit/839e432c19d878cc4260114604274a439d0be626))
52+
53+
## [10.0.0-beta.2](https://github.com/typegoose/mongodb-memory-server/compare/v10.0.0-beta.1...v10.0.0-beta.2) (2024-07-13)
54+
55+
56+
### Fixes
57+
58+
* **MongoBinaryDownloadUrl:** add mapping for Linux Mint 22 ([2ffc024](https://github.com/typegoose/mongodb-memory-server/commit/2ffc024ab6608d2f2d7da230f5ddf7dc4bbf4065))
59+
* trigger release ([8c48020](https://github.com/typegoose/mongodb-memory-server/commit/8c48020816fe19fbcc4f886fcfb96302eaff8714))
60+
61+
## [10.0.0-beta.1](https://github.com/nodkz/mongodb-memory-server/compare/v9.4.0...v10.0.0-beta.1) (2024-06-24)
62+
63+
64+
### ⚠ BREAKING CHANGES
65+
66+
* **resolveConfig:** Default binary version is now "7.0.9"
67+
* **tsconfig:** potentially breaking change upgrading "target" to "es2021" in tsconfig
68+
* Lowest supported NodeJS version is now 16.20.1
69+
70+
* **tsconfig:** update "target" to "es2021" ([abde8ca](https://github.com/nodkz/mongodb-memory-server/commit/abde8ca2ff2ebc077666d496520b3ce0f684ef99))
71+
72+
73+
### Features
74+
75+
* add support for "Explicit Resource Management" ([ab7a73c](https://github.com/nodkz/mongodb-memory-server/commit/ab7a73c14fa80e51ec407d08b120b4ae6ee77ece)), closes [#794](https://github.com/nodkz/mongodb-memory-server/issues/794)
76+
* **getport:** use net0listen by default ([887f1a1](https://github.com/nodkz/mongodb-memory-server/commit/887f1a1e932a8993ef3fd69cf1f65b700c89a77b)), closes [#827](https://github.com/nodkz/mongodb-memory-server/issues/827)
77+
* **resolveConfig:** update default binary version to 7.x ([2436d63](https://github.com/nodkz/mongodb-memory-server/commit/2436d6300bd863efa3300103a3223d3849d0bda3))
78+
* set lowest supported nodejs version to 16.20.1 ([30b302e](https://github.com/nodkz/mongodb-memory-server/commit/30b302e5518c3df92c4b229035b2b229639dfb3c)), closes [#805](https://github.com/nodkz/mongodb-memory-server/issues/805)
79+
80+
81+
### Fixes
82+
83+
* **MongoBinaryDownloadUrl:** change default elementary version to 7 ([ecc4ffe](https://github.com/nodkz/mongodb-memory-server/commit/ecc4ffe2bbf47f3a2cd196d2ffa9a0e22aa4c94d))
84+
* **MongoBinaryDownloadUrl:** change default mint version to 21 ([df97ea8](https://github.com/nodkz/mongodb-memory-server/commit/df97ea8f9edfb97c24a53f9bc6638697df70d85e))
85+
* remove deprecated boolean cleanup argument (stop / cleanup) ([eef706f](https://github.com/nodkz/mongodb-memory-server/commit/eef706f7fef6ffe5caa0f0f8b3b99b168d8d7d2a))
86+
87+
88+
### Dependencies
89+
90+
* **@types/node:** upgrade to version 16.11.7 ([c8a008a](https://github.com/nodkz/mongodb-memory-server/commit/c8a008aacff628ac0e8e7c77683987659411c8a1))
91+
* **async-mutex:** upgrade to version 0.5.0 ([c9f45c9](https://github.com/nodkz/mongodb-memory-server/commit/c9f45c9f032918cbdc73c0953ecc95936c246bac))
92+
* **mongodb:** upgrade to version 6.7.0 ([57e575c](https://github.com/nodkz/mongodb-memory-server/commit/57e575ce49344c79f2ae337da6aa43ada6738746)), closes [#804](https://github.com/nodkz/mongodb-memory-server/issues/804)
93+
* **typescript:** upgrade to version 5.3.3 ([329d79e](https://github.com/nodkz/mongodb-memory-server/commit/329d79e484bf2f7da9e3d0ccf991bdd2cb4282a8))
94+
95+
96+
### Dev-Dependencies
97+
98+
* **@typescript-eslint/*:** upgrade to version 6.21.0 ([b4055a7](https://github.com/nodkz/mongodb-memory-server/commit/b4055a715ee369f675a15059fb88cef38c1aec39))
99+
* **lint-staged:** upgrade to version 14.0.1 ([0f54d29](https://github.com/nodkz/mongodb-memory-server/commit/0f54d29fe8ab51a806bb103609a7e34346c2b220))
100+
* **prettier:** upgrade to version 3.3.0 ([fe1d62d](https://github.com/nodkz/mongodb-memory-server/commit/fe1d62d4fff1849e3fd76d0db745337e6fb693d7))
101+
* **typedoc:** upgrade to version 0.25.13 ([0775c60](https://github.com/nodkz/mongodb-memory-server/commit/0775c60f14ec3026849ed70d24535c013b1d3aa7))
102+
1103
## [9.4.1](https://github.com/typegoose/mongodb-memory-server/compare/v9.4.0...v9.4.1) (2024-07-13)
2104

3105

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ Choose any package, because they are the same. They differ only in the default c
6868

6969
### Requirements
7070

71-
- NodeJS: 14.20.1+
72-
- Typescript: 5.0+ (if used)
71+
- NodeJS: 16.20.1+
72+
- Typescript: 5.3+ (if used)
7373

7474
And one of those (on Linux):
7575

@@ -86,7 +86,7 @@ On Linux, you will also need `libcurl4` (or `libcurl3` on some older distro vers
8686

8787
### Configuring which mongod binary to use
8888

89-
The default behavior is that version `6.0.14` for your OS will be downloaded. By setting [Environment variables](https://typegoose.github.io/mongodb-memory-server/docs/api/config-options) you are able to specify which version and binary will be downloaded:
89+
The default behavior is that version `7.0.11` for your OS will be downloaded. By setting [Environment variables](https://typegoose.github.io/mongodb-memory-server/docs/api/config-options) you are able to specify which version and binary will be downloaded:
9090

9191
```sh
9292
export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz
@@ -128,7 +128,7 @@ const mongod = new MongoMemoryServer({
128128
auth?: boolean, // add "--auth" argument, dont use this directly use top-level "auth"
129129
},
130130
binary?: {
131-
version?: string, // by default '6.0.14'
131+
version?: string, // by default '7.0.11'
132132
downloadDir?: string, // see the documentation on what is chosen by default https://typegoose.github.io/mongodb-memory-server/docs/api/config-options#download_dir
133133
platform?: string, // by default os.platform()
134134
arch?: string, // by default os.arch()

docs/api/config-options.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Example: `ubuntu-18.04`
9393

9494
Option `VERSION` is used to set what mongodb version should be downloaded
9595

96-
Default: `6.0.14` (see [Mongodb Server Versions](../guides/mongodb-server-versions.md) for a complete list and policy)
96+
Default: `7.0.11` (see [Mongodb Server Versions](../guides/mongodb-server-versions.md) for a complete list and policy)
9797

9898
This Option does not have a effect when [`ARCHIVE_NAME`](#archive_name) or [`DOWNLOAD_URL`](#download_url) is defined.
9999

@@ -269,20 +269,6 @@ Also see [ARCHIVE_NAME](#archive_name).
269269
Keep in mind that downloaded binaries will never be automatically deleted.
270270
:::
271271

272-
### EXP_NET0LISTEN
273-
274-
| Environment Variable | PackageJson |
275-
| :------------------: | :---------: |
276-
| `MONGOMS_EXP_NET0LISTEN` | `expNet0Listen` |
277-
278-
Option `EXP_NET0LISTEN` is used to use the experimental (non-predictable) port generation of `net.listen`.
279-
280-
This option will use a random open port, which will lessen the "port is already in use" errors, but will not eliminate them.
281-
282-
This is a experimental option, it maybe removed, renamed or have changed behavior in the future.
283-
284-
Default: `false`
285-
286272
## How to use them in the package.json
287273

288274
To use the config options in the `package.json`, they need to be camelCased (and without `_`), and need to be in the property `config.mongodbMemoryServer`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
id: mongo-memory-dispose-opts
3+
title: 'DisposeOptions'
4+
---
5+
6+
API Documentation of `DisposeOptions`-Interface
7+
8+
## Values for `DisposeOptions`
9+
10+
### enabled
11+
12+
Typings: `enabled?: boolean`
13+
14+
Set whether to stop the manager on `[Symbol.asyncDispose]` calls.
15+
16+
### cleanup
17+
18+
Typings: `cleanup?: Cleanup`
19+
20+
Set custom cleanup options to be used for disposal, see [`cleanup` function](../classes/mongo-memory-server.md#cleanup) (the same options apply for the replset).

docs/api/interfaces/mongo-memory-server-opts.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ API Documentation of `MongoMemoryServerOpts`-Interface
99

1010
### instance
1111

12-
Typings: `instance?: MemoryServerInstanceOpts`
12+
Typings: `instance?: MemoryServerInstanceOpts & ExtraOptions`
1313

1414
Set custom options based on [`MongoMemoryInstanceOpts`](./mongo-memory-instance-opts.md), but ignores some properties:
1515

1616
- `auth` is ignored because it is set via [auth](#auth) property.
1717

18+
Extra options specific to [`MongoMemoryServer` class](../classes/mongo-memory-server.md):
19+
20+
- `portGeneration`: enable / disable port generation, enabled by default.
21+
1822
### binary
1923

2024
Typings: `binary?: MongoBinaryOpts`
@@ -32,3 +36,9 @@ Set custom spawn options for spawning processes, uses [`SpawnOptions`](https://n
3236
Typings: `auth?: AutomaticAuth`
3337

3438
Set custom Authentication options for the instance, uses [`AutomaticAuth`](./mongo-memory-server-automaticauth.md).
39+
40+
### dispose
41+
42+
Typings: `dispose?: DisposeOptions`
43+
44+
Set custom behavior for when `[Symbol.asyncDispose]` is called, uses [`DisposeOptions`](./mongo-dispose-opts.md).

docs/api/interfaces/replset-opts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,9 @@ Set how many ReplSet members to spawn, this number will be deducted from length
9191
:::tip
9292
It is recommended to set this number to a **odd** number, and try to never have it be **even**, see [MongoDB Deploy an Odd Number of Members](https://www.mongodb.com/docs/v5.2/core/replica-set-architectures/#deploy-an-odd-number-of-members).
9393
:::
94+
95+
### dispose
96+
97+
Typings: `dispose?: DisposeOptions`
98+
99+
Set custom behavior for when `[Symbol.asyncDispose]` is called, uses [`DisposeOptions`](./mongo-dispose-opts.md).

docs/guides/faq.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ Since `8.4.0` objects can also be used instead of just booleans for parameter in
2121

2222
For Example `.stop({ doCleanup: false })` can be used instead of `.stop(false)`.
2323
:::
24+
25+
### Does this package support Explicit Resource Management?
26+
27+
Yes, `[Symbol.asyncDispose]` is implemented for all manager classes, behavior can be configured via `dispose` options:
28+
29+
- [`MongoMemoryServerOpts.dispose`](../api/interfaces/mongo-memory-server-opts.md#dispose)
30+
- [`ReplSetOpts.dispose`](../api/interfaces/replset-opts.md#dispose)
31+
32+
:::note
33+
Note that when using `await using server =` that `[Symbol.asyncDispose]` is called at the end of the scope even if the value is reassigned to something out of the current scope.
34+
:::

docs/guides/integration-examples/test-runners.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export = async function globalSetup() {
5656
process.env.MONGO_URI = `mongodb://${config.IP}:${config.Port}`;
5757
}
5858

59-
// The following is to make sure the database is clean before an test starts
59+
// The following is to make sure the database is clean before a test suite starts
6060
const conn = await mongoose.connect(`${process.env.MONGO_URI}/${config.Database}`);
6161
await conn.connection.db.dropDatabase();
6262
await mongoose.disconnect();
@@ -89,7 +89,7 @@ beforeAll(async () => {
8989
});
9090

9191
afterAll(async () => {
92-
// put your client disconnection code here, example with mongodb:
92+
// put your client disconnection code here, example with mongoose:
9393
await mongoose.disconnect();
9494
});
9595
```
@@ -109,17 +109,16 @@ Keep in mind that jest's global-setup and global-teardown do **not** share a env
109109

110110
Start Mocha with `--timeout 60000` cause first download of MongoDB binaries may take a time.
111111

112-
```js
112+
```ts
113113
import mongoose from 'mongoose';
114114
import { MongoMemoryServer } from 'mongodb-memory-server';
115115

116116
let mongoServer;
117-
const opts = { useMongoClient: true }; // remove this option if you use mongoose 5 and above
118117

119118
before(async () => {
120119
mongoServer = await MongoMemoryServer.create();
121120
const mongoUri = mongoServer.getUri();
122-
await mongoose.connect(mongoUri, opts);
121+
await mongoose.connect(mongoUri);
123122
});
124123

125124
after(async () => {
@@ -130,16 +129,16 @@ after(async () => {
130129
describe('...', () => {
131130
it('...', async () => {
132131
const User = mongoose.model('User', new mongoose.Schema({ name: String }));
133-
const cnt = await User.count();
132+
const cnt = await User.countDocuments();
134133
expect(cnt).to.equal(0);
135134
});
136135
});
137136
```
138137

139138
## AVA test runner
140139

141-
For AVA written [detailed tutorial](https://github.com/zellwk/ava/blob/8b7ccba1d80258b272ae7cae6ba4967cd1c13030/docs/recipes/endpoint-testing-with-mongoose.md) how to test mongoose models by @zellwk.
140+
For AVA there is a [detailed written tutorial](https://github.com/zellwk/ava/blob/8b7ccba1d80258b272ae7cae6ba4967cd1c13030/docs/recipes/endpoint-testing-with-mongoose.md) on how to test mongoose models with mongodb-memory-server by [@zellwk](https://github.com/zellwk).
142141

143142
:::note
144-
Note that this mentioned tutorial is pre 7.x
143+
Note that this tutorial is pre mongodb-memory-server 7.x.
145144
:::

docs/guides/migration/migrate10.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
id: migrate10
3+
title: 'Migrate to version 10.0.0'
4+
---
5+
6+
Here are the Important changes made for 10.0.0
7+
8+
:::caution Important, Read this first
9+
This Guide is written for migration from version `9.4.1` to `10.0.0`, for versions `>10.0.0 <11.0.0`, please consult the [CHANGELOG](https://github.com/typegoose/mongodb-memory-server/blob/master/CHANGELOG.md)
10+
:::
11+
12+
## Breaking Changes
13+
14+
### Minimal NodeJS version is now `16`
15+
16+
With 10.0.0 the minimal nodejs required is `16.20.1`.
17+
18+
### Mongodb Driver Version upgraded to 6.x
19+
20+
The used MongoDB Driver version is now `6.7.0`.
21+
22+
### Default binary version is now 7.x
23+
24+
The default binary version has been upgraded from `6.0.x` to `7.0.x`. For more specifics see [mongodb-server-versions](../mongodb-server-versions.md).
25+
26+
:::note
27+
In mongodb `7.0.0` storage engine `ephemeralForTest` has been removed, mongodb-memory-server will automatically translate any occurrence to `wiredTiger` with a warning.
28+
29+
It is recommended to run the tests against a tmpfs or equivalent (default `/tmp` on linux / macos).
30+
:::
31+
32+
## Non-Breaking changes / Additions
33+
34+
### Compiler target is now `es2021`
35+
36+
The tsconfig `target` option has been updated to `es2021`, which will result in less polyfills.
37+
This should be a non-breaking change.
38+
39+
### Getport now uses `net0listen` by default
40+
41+
This means a port is now generated by the engine (like nodejs) itself, previously known as `EXP_NET0LISTEN`.
42+
This should reduce amount of `Max port tries exceeded` errors.
43+
44+
### Allow setting port generation in MongoMemoryServer
45+
46+
Starting with 10.0 there is a new option to set whether port generation is enabled or not on `MongoMemoryServer` called `portGeneration`. (default: `true`)
47+
48+
(Note that the `forceSamePort` parameter in `.start` will overwrite this option)

0 commit comments

Comments
 (0)