Ticket: Timeouts - Return from api incorrect

Hi all,

The test npm test -t timeouts is passing but the status page tells me that Timeouts: The return from the api was incorrect. What should i recheck ? Thanks.

Make sure you actually changed the appropriate setting in both places. This is actually stated on the question page.

For the “unit tests” you edit the setting in : test/config/mongoEnvironment.js

But for the “mflix” application you actually need to change the index.js

Testing and Running the Application


The unit test only has access to DAO methods, but the write timeout for the MFlix application is set in the index.js file.

However, the write timeout for the testing environment is set intest/config/mongoEnvironment.js, so you can test your changes there and the unit test will tell you if something is wrong.

When the unit test passes, make sure to update the code in src/index.js so you can retrieve the validation code from the integration test.

Yes i did change the settings in both mongoEnvironment.js & index.js

Your result says you likely did not. Check it again.

Please note this is not a chat room. If you get a response you probably should walk away and look at it thoroughly instead of responding right away.

Could you share what your connection information looks like now after setting the appropriate values in the options argument?

Make sure you’re on the src/index.js file and not on the index.js file which is in the root folder of the mflix app.


Hi Nathan, Wouldn’t that be sharing the answer ? I assume you are referring to the connection information in src/index and test/mongoEnvironment.js. In test/mongoEnvironment.js i have

async setup() {
    if (!this.global.mflixClient) {
          this.global.mflixClient = await MongoClient.connect(
                    //  the poolsize and write timeout entry here
            { useNewUrlParser: true }
      await super.setup()

In src/index.js i have ,

// the pool size and write timeout entry here
  { useNewUrlParser: true },

I am on src/index.js. I have put the respective connection parameters to src/index.js and test/mongoEnvironment.js in my answer to @nathan.leniz below. Thank you.

If what you mean you did was basically:

  { notThePoolSizeOption: 999, notTheTimeout: 999 },
  { useNewUrlParser: true }

Then that would be incorrect as the “options” part is one section and not two.

You should have something like:

     notThePoolSizeOption: 999,
     notTheTimeout: 999,
     useNewUrlParser: true

And of course the actual named options are all in the MongoClient documentation, not to mention the fact that they are both named in the unit tests of course.

The actual getConfiguration() method is in the moviesDAO and it’s something you don’t need to change. Both the front end /status and the unit tests are reading from this method, so the only difference is the two named files and what options you actually put in them.

11 posts were split to a new topic: Ticket: Timeouts - unit test fails