1 | const {MongoClient} = require('mongodb');
|
2 | const {shouldUseSharedDBForAllJestWorkers} = require('./helpers');
|
3 |
|
4 | describe('parallelism: first worker', () => {
|
5 | const uri = global.__MONGO_URI__;
|
6 | let connection;
|
7 | let db;
|
8 |
|
9 | beforeAll(async () => {
|
10 | connection = await MongoClient.connect(uri, {
|
11 | useNewUrlParser: true,
|
12 | useUnifiedTopology: true,
|
13 | });
|
14 | db = await connection.db();
|
15 | });
|
16 |
|
17 | afterAll(async () => {
|
18 | await connection.close();
|
19 | });
|
20 |
|
21 | it('should have separate database', async () => {
|
22 | const collection = db.collection('parallelism-test');
|
23 |
|
24 | await collection.insertOne({a: 1});
|
25 | const count = await collection.count({});
|
26 |
|
27 | if (!shouldUseSharedDBForAllJestWorkers()) {
|
28 | expect(count).toBe(1);
|
29 | }
|
30 | });
|
31 | });
|