I have a www.js file in my bin folder. Which is responsible for starting my server application.
const http = require('http');
const app = require('../app'); // This is my express application instance.
http.createServer(app).listen(process.env.SERVER_PORT || 3000);
As you can see there is no export here. node will run this file (cmd: node bin/www) and my server will start. However it still has some logic in it that I need to test.
Test cases I though:
- It should create server with my express instance
- It should listen from port 3000 if there is no environment variable provided
- It should listen from port that is provided from environment variable if it's given.
I use jest for my tests.
Since this file does not export anything, I cannot import it in a jest test file. How can I test now?