I have server that should perform some job before start, and log about success. For example:
const http = require('http');
function startServer() {
const server = http.createServer((req, res) => {
res.write('hello\n');
res.end();
}).listen(3000);
console.log('server is ready');
}
//as 'job' we will use timer
setTimeout(startServer, 10000);
I need create integration tests that will check:
- log contains information about server is ready
- request/response work correct
Questions:
- Should I run server for every test case or enough single instance?
- Job before start server takes some time. How I know when need send request? I cannot rely on log since in this case second test will dependent on result of first one.
Aucun commentaire:
Enregistrer un commentaire