I'm testing my NodeJS application with supertest. At the end of my app.js I expose my app, so I can use it within the test.js.
///////////////////
// https options
var options = {
key: fs.readFileSync("./private/keys/Server.key"),
cert: fs.readFileSync("./private/certs/Server.crt"),
ca: fs.readFileSync("./private/ca/CA.crt"),
requestCert: true,
rejectUnauthorized: false
};
///////////////////
// start https server
var server = https.createServer(options, app).listen(app.get("port"), function(){
console.log('Server listening on port ' + app.get('port'));
});
exports = module.exports = server;
When I require my server in my test.js the path of options will cause an error, since my test.js is in the directory ./test/test.js, whereas app.js is in ./app.js.
I'm struggeling to find a clean solution for this problem.