0

I am using DI to inject config object into classes. In one end-to-end test I have scenario where I need to compare results of two requests - one with original config and another with modified config object.

I do not want to overwrite global config file in my end-to-end test, but I am not sure how to define and use it in the test if the config is used by many classes inside the Node.js application. I am currently using mocha/chai and supertest to send requests. Please advise me good test design strategy. Thank you!

Angelina
  • 1,473
  • 2
  • 16
  • 34
  • So how do you store your config? Why don't you want to overwrite global config, since if it's stored in memory it shouldn't have no side effects once the tests are done? Also worth considering that DI isn't really needed if it's just for the tests. – FINDarkside Jan 30 '18 at 09:24
  • config is provided to all classes using DI. That's why I call it global. If I start overwriting some properties during the tests, I am afraid that it will break the functionality of the application after the tests are finished. In this set-up after the test finished I need to make sure that I change the properties in the config to the initial values. What if this step is missed. I feel it is not good practice, but not sure how to do it better – Angelina Jan 30 '18 at 09:30

0 Answers0