In the example section of SuperTest (v0.15.0), it mentions something about ephemeral port:
You may pass an http.Server, or a Function to request() - if the server is not already listening for connections then it is bound to an ephemeral port for you so there is no need to keep track of ports. - https://github.com/visionmedia/supertest#example
Let’s dissect this sentence. There are a few key concepts to grasp:
The request function will accept either a function or an http.Server object.
When does the server not listening for connections?
What is an ephemeral port?
Taking a peek at the index.js file in SuperTest source code, it is easy to see that it accepts both function and http.Server object, but prefer latter:
// See `index.js` in [SuperTest] source code.
if ('function' == typeof app) app = http.createServer(app);
Only when initiating an Express app, it returns a function, not an object. And follows up on lib/test.js, when SuperTest detects the created server is yet to bind to any port number, it will invoke app.listen(0), so called ephemeral port. In fact, it is just a random port.
When something is ephemeral, it last for a very short time. When allowing a server to accept connections, we usually do is setting the server to listen on a specific port:
What if setting this to 0 like above or omit this port number?
Using Vagrant file provision in a Windows host, the line endings are not converted from CRLF to LF (Linux systems). So, code cannot be executed properly in the guest Linux system. And also this is a frequently occurred message for working with Windows:
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory.
One solution is to use UNIX line ending (LF) even in Windows, hence no conversion is needed. This is done by setting:
$ git config --global core.autocrlf input
Which means when committing the code to a remote repository, the line ending will be convert from CRLF to LF if any, but when checking out from the remote directory, no conversion from LF to CRLF is performed.