@tsed/testcontainers-mongo 7.82.3 → 7.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestContainersMongo = void 0;
4
4
  const common_1 = require("@tsed/common");
5
- const mongoose_1 = require("@tsed/mongoose");
5
+ const mongodb_1 = require("mongodb");
6
6
  const ContainerUtils_js_1 = require("./ContainerUtils.js");
7
7
  class TestContainersMongo {
8
8
  static { this.startMongoServer = ContainerUtils_js_1.startMongoServer; }
@@ -10,16 +10,20 @@ class TestContainersMongo {
10
10
  static { this.getMongoConnectionsOptions = ContainerUtils_js_1.getMongoConnectionsOptions; }
11
11
  static { this.getMongoConnectionOptions = ContainerUtils_js_1.getMongoConnectionOptions; }
12
12
  static create(options = {}) {
13
+ TestContainersMongo.configuration = (0, ContainerUtils_js_1.getMongoConnectionsOptions)();
13
14
  return common_1.PlatformTest.create({
14
15
  ...options,
15
- mongoose: (0, ContainerUtils_js_1.getMongoConnectionsOptions)()
16
+ mongoose: TestContainersMongo.configuration
16
17
  });
17
18
  }
18
19
  static bootstrap(mod, opts = {}) {
19
- return () => common_1.PlatformTest.bootstrap(mod, {
20
- mongoose: (0, ContainerUtils_js_1.getMongoConnectionsOptions)(),
21
- ...opts
22
- })();
20
+ return () => {
21
+ TestContainersMongo.configuration = (0, ContainerUtils_js_1.getMongoConnectionsOptions)();
22
+ return common_1.PlatformTest.bootstrap(mod, {
23
+ mongoose: TestContainersMongo.configuration,
24
+ ...opts
25
+ })();
26
+ };
23
27
  }
24
28
  static async reset(collectionName) {
25
29
  if (typeof collectionName === "string") {
@@ -27,14 +31,19 @@ class TestContainersMongo {
27
31
  }
28
32
  return common_1.PlatformTest.reset();
29
33
  }
30
- static async cleanCollection(collectionName) {
31
- const service = common_1.PlatformTest.injector.get(mongoose_1.MongooseService);
32
- const { collections } = service.get("default");
33
- if (!collections[collectionName]) {
34
- console.error(`Collection ${collectionName} not found. Here available collection names: ${Object.keys(collections)}`);
35
- return;
34
+ static async cleanCollection(collectionName, mongoSettings = TestContainersMongo.configuration) {
35
+ try {
36
+ const client = new mongodb_1.MongoClient(mongoSettings[0].url, {
37
+ directConnection: true
38
+ });
39
+ await client.connect();
40
+ const db = client.db();
41
+ await db.collection(collectionName).deleteMany({});
42
+ await client.close();
43
+ }
44
+ catch (er) {
45
+ console.error(`Collection ${collectionName} not found. ${er.message} ${er.stack}`);
36
46
  }
37
- await collections[collectionName].deleteMany({});
38
47
  }
39
48
  }
40
49
  exports.TestContainersMongo = TestContainersMongo;
@@ -1 +1 @@
1
- {"version":3,"file":"TestContainersMongo.js","sourceRoot":"","sources":["../../../src/services/TestContainersMongo.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAC1C,6CAA+C;AAC/C,2DAA6H;AAE7H,MAAa,mBAAmB;aACvB,qBAAgB,GAAG,oCAAgB,CAAC;aACpC,oBAAe,GAAG,mCAAe,CAAC;aAClC,+BAA0B,GAAG,8CAA0B,CAAC;aACxD,8BAAyB,GAAG,6CAAyB,CAAC;IAE7D,MAAM,CAAC,MAAM,CAAC,UAAuC,EAAE;QACrD,OAAO,qBAAY,CAAC,MAAM,CAAC;YACzB,GAAG,OAAO;YACV,QAAQ,EAAE,IAAA,8CAA0B,GAAE;SACvC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,GAAY,EAAE,OAAoC,EAAE;QACnE,OAAO,GAAG,EAAE,CACV,qBAAY,CAAC,SAAS,CAAC,GAAG,EAAE;YAC1B,QAAQ,EAAE,IAAA,8CAA0B,GAAE;YACtC,GAAG,IAAI;SACR,CAAC,EAAE,CAAC;IACT,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,cAAuB;QACxC,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YACtC,MAAM,mBAAmB,CAAC,eAAe,CAAC,cAAc,CAAC,CAA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,CAAC,GAAG,EAAE;gBACjC,QAAQ,EAAE,mBAAmB,CAAC,aAAa;gBAC3C,GAAG,IAAI;aACR,CAAC,EAAE,CAAC;QACP,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,cAAuB;QACxC,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YACtC,MAAM,mBAAmB,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;SAC3D;QAED,OAAO,qBAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,aAAa,GAAG,mBAAmB,CAAC,aAAa;QACpG,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,qBAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBACnD,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;YACvB,MAAM,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACnD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;SACtB;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,cAAc,cAAc,eAAe,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;SACpF;IACH,CAAC;;AAhDH,kDAiDC"}
@@ -1,5 +1,5 @@
1
1
  import { PlatformTest } from "@tsed/common";
2
- import { MongooseService } from "@tsed/mongoose";
2
+ import { MongoClient } from "mongodb";
3
3
  import { getMongoConnectionOptions, getMongoConnectionsOptions, startMongoServer, stopMongoServer } from "./ContainerUtils.js";
4
4
  export class TestContainersMongo {
5
5
  static { this.startMongoServer = startMongoServer; }
@@ -7,16 +7,20 @@ export class TestContainersMongo {
7
7
  static { this.getMongoConnectionsOptions = getMongoConnectionsOptions; }
8
8
  static { this.getMongoConnectionOptions = getMongoConnectionOptions; }
9
9
  static create(options = {}) {
10
+ TestContainersMongo.configuration = getMongoConnectionsOptions();
10
11
  return PlatformTest.create({
11
12
  ...options,
12
- mongoose: getMongoConnectionsOptions()
13
+ mongoose: TestContainersMongo.configuration
13
14
  });
14
15
  }
15
16
  static bootstrap(mod, opts = {}) {
16
- return () => PlatformTest.bootstrap(mod, {
17
- mongoose: getMongoConnectionsOptions(),
18
- ...opts
19
- })();
17
+ return () => {
18
+ TestContainersMongo.configuration = getMongoConnectionsOptions();
19
+ return PlatformTest.bootstrap(mod, {
20
+ mongoose: TestContainersMongo.configuration,
21
+ ...opts
22
+ })();
23
+ };
20
24
  }
21
25
  static async reset(collectionName) {
22
26
  if (typeof collectionName === "string") {
@@ -24,14 +28,19 @@ export class TestContainersMongo {
24
28
  }
25
29
  return PlatformTest.reset();
26
30
  }
27
- static async cleanCollection(collectionName) {
28
- const service = PlatformTest.injector.get(MongooseService);
29
- const { collections } = service.get("default");
30
- if (!collections[collectionName]) {
31
- console.error(`Collection ${collectionName} not found. Here available collection names: ${Object.keys(collections)}`);
32
- return;
31
+ static async cleanCollection(collectionName, mongoSettings = TestContainersMongo.configuration) {
32
+ try {
33
+ const client = new MongoClient(mongoSettings[0].url, {
34
+ directConnection: true
35
+ });
36
+ await client.connect();
37
+ const db = client.db();
38
+ await db.collection(collectionName).deleteMany({});
39
+ await client.close();
40
+ }
41
+ catch (er) {
42
+ console.error(`Collection ${collectionName} not found. ${er.message} ${er.stack}`);
33
43
  }
34
- await collections[collectionName].deleteMany({});
35
44
  }
36
45
  }
37
46
  //# sourceMappingURL=TestContainersMongo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TestContainersMongo.js","sourceRoot":"","sources":["../../../src/services/TestContainersMongo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAA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AK,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,aAAa,GAAG,mBAAmB,CAAC,aAAa;QACpG,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBACnD,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;YACvB,MAAM,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACnD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;SACtB;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,cAAc,cAAc,eAAe,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;SACpF;IACH,CAAC"}
@@ -1,11 +1,41 @@
1
+ /// <reference types="mongoose/types/aggregate.js" />
2
+ /// <reference types="mongoose/types/callback.js" />
3
+ /// <reference types="mongoose/types/collection.js" />
4
+ /// <reference types="mongoose/types/connection.js" />
5
+ /// <reference types="mongoose/types/cursor.js" />
6
+ /// <reference types="mongoose/types/document.js" />
7
+ /// <reference types="mongoose/types/error.js" />
8
+ /// <reference types="mongoose/types/expressions.js" />
9
+ /// <reference types="mongoose/types/helpers.js" />
10
+ /// <reference types="mongoose/types/middlewares.js" />
11
+ /// <reference types="mongoose/types/indexes.js" />
12
+ /// <reference types="mongoose/types/models.js" />
13
+ /// <reference types="mongoose/types/mongooseoptions.js" />
14
+ /// <reference types="mongoose/types/pipelinestage.js" />
15
+ /// <reference types="mongoose/types/populate.js" />
16
+ /// <reference types="mongoose/types/query.js" />
17
+ /// <reference types="mongoose/types/schemaoptions.js" />
18
+ /// <reference types="mongoose/types/schematypes.js" />
19
+ /// <reference types="mongoose/types/session.js" />
20
+ /// <reference types="mongoose/types/types.js" />
21
+ /// <reference types="mongoose/types/utility.js" />
22
+ /// <reference types="mongoose/types/validation.js" />
23
+ /// <reference types="mongoose/types/virtuals.js" />
24
+ /// <reference types="mongoose" />
25
+ /// <reference types="mongoose/types/inferschematype.js" />
1
26
  import { getMongoConnectionOptions, getMongoConnectionsOptions, startMongoServer, stopMongoServer } from "./ContainerUtils.js";
2
27
  export declare class TestContainersMongo {
3
28
  static startMongoServer: typeof startMongoServer;
4
29
  static stopMongoServer: typeof stopMongoServer;
5
30
  static getMongoConnectionsOptions: typeof getMongoConnectionsOptions;
6
31
  static getMongoConnectionOptions: typeof getMongoConnectionOptions;
32
+ private static configuration;
7
33
  static create(options?: Partial<TsED.Configuration>): Promise<void>;
8
34
  static bootstrap(mod: unknown, opts?: Partial<TsED.Configuration>): () => Promise<void>;
9
35
  static reset(collectionName?: string): Promise<void>;
10
- static cleanCollection(collectionName: string): Promise<void>;
36
+ static cleanCollection(collectionName: string, mongoSettings?: {
37
+ id: string;
38
+ url: string;
39
+ connectionOptions: import("mongoose").ConnectOptions;
40
+ }[]): Promise<void>;
11
41
  }
@@ -1,11 +1,41 @@
1
+ /// <reference types="mongoose/types/aggregate.js" />
2
+ /// <reference types="mongoose/types/callback.js" />
3
+ /// <reference types="mongoose/types/collection.js" />
4
+ /// <reference types="mongoose/types/connection.js" />
5
+ /// <reference types="mongoose/types/cursor.js" />
6
+ /// <reference types="mongoose/types/document.js" />
7
+ /// <reference types="mongoose/types/error.js" />
8
+ /// <reference types="mongoose/types/expressions.js" />
9
+ /// <reference types="mongoose/types/helpers.js" />
10
+ /// <reference types="mongoose/types/middlewares.js" />
11
+ /// <reference types="mongoose/types/indexes.js" />
12
+ /// <reference types="mongoose/types/models.js" />
13
+ /// <reference types="mongoose/types/mongooseoptions.js" />
14
+ /// <reference types="mongoose/types/pipelinestage.js" />
15
+ /// <reference types="mongoose/types/populate.js" />
16
+ /// <reference types="mongoose/types/query.js" />
17
+ /// <reference types="mongoose/types/schemaoptions.js" />
18
+ /// <reference types="mongoose/types/schematypes.js" />
19
+ /// <reference types="mongoose/types/session.js" />
20
+ /// <reference types="mongoose/types/types.js" />
21
+ /// <reference types="mongoose/types/utility.js" />
22
+ /// <reference types="mongoose/types/validation.js" />
23
+ /// <reference types="mongoose/types/virtuals.js" />
24
+ /// <reference types="mongoose" />
25
+ /// <reference types="mongoose/types/inferschematype.js" />
1
26
  import { getMongoConnectionOptions, getMongoConnectionsOptions, startMongoServer, stopMongoServer } from "./ContainerUtils.js";
2
27
  export declare class TestContainersMongo {
3
28
  static startMongoServer: typeof startMongoServer;
4
29
  static stopMongoServer: typeof stopMongoServer;
5
30
  static getMongoConnectionsOptions: typeof getMongoConnectionsOptions;
6
31
  static getMongoConnectionOptions: typeof getMongoConnectionOptions;
32
+ private static configuration;
7
33
  static create(options?: Partial<TsED.Configuration>): Promise<void>;
8
34
  static bootstrap(mod: unknown, opts?: Partial<TsED.Configuration>): () => Promise<void>;
9
35
  static reset(collectionName?: string): Promise<void>;
10
- static cleanCollection(collectionName: string): Promise<void>;
36
+ static cleanCollection(collectionName: string, mongoSettings?: {
37
+ id: string;
38
+ url: string;
39
+ connectionOptions: import("mongoose").ConnectOptions;
40
+ }[]): Promise<void>;
11
41
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/testcontainers-mongo",
3
3
  "description": "A module to test Ts.ED code that use MongoDB as database using Test Containers",
4
4
  "type": "commonjs",
5
- "version": "7.82.3",
5
+ "version": "7.83.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -30,22 +30,22 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@testcontainers/mongodb": ">=10.11.0",
33
- "@tsed/barrels": "7.82.3",
34
- "@tsed/common": "7.82.3",
35
- "@tsed/core": "7.82.3",
36
- "@tsed/di": "7.82.3",
37
- "@tsed/mongoose": "7.82.3",
38
- "@tsed/typescript": "7.82.3",
33
+ "@tsed/barrels": "7.83.0",
34
+ "@tsed/common": "7.83.0",
35
+ "@tsed/core": "7.83.0",
36
+ "@tsed/di": "7.83.0",
37
+ "@tsed/typescript": "7.83.0",
39
38
  "eslint": "^8.57.0",
39
+ "mongodb": "6.8.0",
40
40
  "testcontainers": ">=10.11.0",
41
41
  "typescript": "4.9.5"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@testcontainers/mongodb": ">=10.11.0",
45
- "@tsed/common": "7.82.3",
46
- "@tsed/core": "7.82.3",
47
- "@tsed/di": "7.82.3",
48
- "@tsed/mongoose": "7.82.3",
45
+ "@tsed/common": "7.83.0",
46
+ "@tsed/core": "7.83.0",
47
+ "@tsed/di": "7.83.0",
48
+ "mongodb": ">=6",
49
49
  "testcontainers": ">=10.11.0"
50
50
  },
51
51
  "repository": "https://github.com/tsedio/tsed",
package/readme.md CHANGED
@@ -91,7 +91,13 @@ export default defineConfig({
91
91
 
92
92
  :::
93
93
 
94
- ### Usage
94
+ ## Usage
95
+
96
+ ### @tsed/mongoose
97
+
98
+ #### Unit test
99
+
100
+ Use the `TestContainersMongo.create` method to start the mongo server before your test:
95
101
 
96
102
  ```ts
97
103
  import {PlatformTest} from "@tsed/common";
@@ -148,6 +154,41 @@ describe("UserModel", () => {
148
154
  });
149
155
  ```
150
156
 
157
+ #### Integration test
158
+
159
+ Just use the `TestContainersMongo.bootstrap` method to start the mongo server before your test:
160
+
161
+ ```ts
162
+ beforeEach(() => TestContainersMongo.bootstrap(Server, {}));
163
+ ```
164
+
165
+ ### Mikro ORM
166
+
167
+ TestContainersMongo provides a method to get the connection options for MikroORM:
168
+
169
+ ```ts
170
+ import {EntityManager, MikroORM} from "@mikro-orm/core";
171
+ import {defineConfig} from "@mikro-orm/mongodb";
172
+ import {PlatformTest} from "@tsed/common";
173
+ import {TestContainersMongo} from "@tsed/testcontainers-mongo";
174
+
175
+ beforeEach(async () => {
176
+ const mongoSettings = TestContainersMongo.getMongoConnectionOptions();
177
+ const bstrp = PlatformTest.bootstrap(Server, {
178
+ disableComponentScan: true,
179
+ imports: [MikroOrmModule],
180
+ mikroOrm: [
181
+ defineConfig({
182
+ clientUrl: mongoSettings.url,
183
+ driverOptions: mongoSettings.connectionOptions,
184
+ entities: [User],
185
+ subscribers: [UnmanagedEventSubscriber1, new UnmanagedEventSubscriber2()]
186
+ })
187
+ ]
188
+ });
189
+ });
190
+ ```
191
+
151
192
  ## Contributors
152
193
 
153
194
  Please read [contributing guidelines here](https://tsed.io/contributing.html)