1

I have made some changes to my file "config.js" which is required in the nmodule to be tested "file.js".

fileTest.js :
__________________________
    var file = require("file");
    var proxyquire = require("proxyquire").noPreserveCache();
    var pathStubb = {};
    var configStub = proxyquire("../modules/file.js", { "./config": pathStubb });

    pathStubb = { currentEnv: 'AAAA',
                host: 'www.wwf.com',
                port: '8085',
                path: '/somepath',
                method: 'POST',
                headers: [Function],
                optionspost: {
                    "host" : "ww.google.com",
                    "port" : "8086",
                    "path" : "mt.html",
                    "method" : "GET"
                }
            };
config.js:
_________________________________________
modules.export = { currentEnv: 'OOOO',
                host: 'www.wwf.com',
                port: '8085',
                path: '/somepath',
                method: 'POST',
                headers: [Function],
                optionspost: {
                    "host" : "ww.google.com",
                    "port" : "8086",
                    "path" : "mt.html",
                    "method" : "GET"
                }
            };
file.js:
_____________________________________

var configFile = var require("./config.js");

//some code

I have created a file fileTest.js which has two descrbe methods for testing two different scenarios of file.js.

  1. Test cases when currentEnv in config.js is "AAAA"
  2. Test cases when currentEnv in config.js is "OOOO"

I have created test cases normally for currentEnv "AAAA" and its working file. But the part which is to be covered if the currentEnv is "OOO" is not getting coverered in file.js. I have to override the object in config.js for both kind of test cases. Can anyone help me with this.

Surya
  • 628
  • 3
  • 9
  • 26

0 Answers0