Closed ckpiggy closed 6 years ago
I'm writing a endpoint test for my api. Instead of creating a http server, I want to use the listener function to simulate the server How can I got a full function F.listener without creating a http server listening any port?
Currently I create a method in index.js
F.prepare_listener = function(){ const http = require('http') extend_request(http.IncomingMessage.prototype) extend_response(http.ServerResponse.prototype) F.$configure_configs() F.$configure_versions() F.$configure_workflows() F.$configure_sitemap() F.isTest && F.$configure_configs('config-test', true) }
But actually, I don't know if this is a proper way to setup the listener. How should I do?
Why don't you want to create a server? It's a big problem to simulate the server.
I just figure out I can use F.http to start a server before all the test start and use F.listener with supertest XD
I'm writing a endpoint test for my api. Instead of creating a http server, I want to use the listener function to simulate the server How can I got a full function F.listener without creating a http server listening any port?
Currently I create a method in index.js
But actually, I don't know if this is a proper way to setup the listener. How should I do?