UNPKG

771 BJavaScriptView Raw
1const {MongoClient} = require('mongodb');
2const {shouldUseSharedDBForAllJestWorkers} = require('./helpers');
3
4describe('parallelism: second 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.insertMany([{a: 1}, {b: 2}]);
25 const count = await collection.count({});
26
27 if (!shouldUseSharedDBForAllJestWorkers()) {
28 expect(count).toBe(2);
29 }
30 });
31});