Connection Pooling not working for the poolSize option

Hi I have a problem with the connection pooling section of the mflix application.

I have changed the connection options for the MongClient connect method like so:

  {poolSize: 50, useNewUrlParser: true},

, but I still get an error when I run the jest test suite

> server@1.0.0 test D:\Javascript\mongodb\mflix-js
> jest --passWithNoTests "connection-pooling"

Determining test suites to run...Setup Mongo Connection
(node:12716) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12716) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
 FAIL  test/connection-pooling.test.js
  Connection Pooling
    × Connection pool size is 50 (282ms)

  ● Connection Pooling › Connection pool size is 50

    expect(received).toBe(expected) // equality

    Expected: 50
    Received: undefined

       8 |   test("Connection pool size is 50", async () => {
       9 |     const response = await MoviesDAO.getConfiguration()
    > 10 |     expect(response.poolSize).toBe(50)
         |                               ^
      11 |   })
      12 | })
      13 |

      at toBe (test/connection-pooling.test.js:10:31)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)
      at (node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.109s
Ran all test suites matching /connection-pooling/i.
Teardown Mongo Connection
npm ERR! Test failed.  See above for more details.

Instead I use the URI string options to specify the pool size and it works


Anyone that can Help?

Nevermind, I Realised my problem.
Node test environment Jest is set up to run with different connections options found in


1 Like

Hi , May I know did you fixed that issue? Because I am facing same issue :slight_smile:

I was facing same issue because I had changed the poolSize in index.js and was expecting the test will pass it . I noticed that I should have firstly change the poolSize on test file which mongoEnvironment.js. After that the test passed it.Maybe your issue regarding that too.