You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even that we created app-factory.js to create app and also resolved untestable app #141 , this fix works only for decouple created app from server (app.js). So it works for unit test.
But for integration test, not usually.
If we need to test if #163 if rate limit is blocking correctly `/health-check', we gonna need to send X calls till the rate limit is reached.
After this test, we need to restart server, otherwise we will not be able to request this endpoint anymore as it has alreasy reached rate-limit.
The text was updated successfully, but these errors were encountered:
I did some R&D on that.
Looks like a lot of other users that use the hyped express have this issue. So guess what? There's a lib for that.
supertest may do the trick. According to docs you don't have to start server to run tests. They say:
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.
We may find some tricky blockers in our way, as we have a very specific startup configuration load flow.
also a possible workaround:
on app.jsalso export httpServer right after httpServer = app.listen... line.
and in before hook:
constapp=require('../../../server/app')Beofre({timeout: 600*1000},(done)=>{// mock init external endpointsconstinitMock=newInitMock()initMock.passportConfigEndpoint()initMock.umaTokenEndpoint()initMock.umaConfigurationEndpoint()// waits for the server to start (app.listen)app.on('appStarted',()=>{console.log('app started...')// import again, after server started = server instanceletserver=require('../../../server/app')// restarting...server.close()server=app.listen(8090,()=>{console.log('Server listening for tests....')app.emit('appStarted')// event emitter for tests})done()})})
Even that we created
app-factory.js
to create app and also resolved untestable app #141 , this fix works only for decouple created app from server (app.js). So it works for unit test.But for integration test, not usually.
If we need to test if #163 if rate limit is blocking correctly `/health-check', we gonna need to send X calls till the rate limit is reached.
After this test, we need to restart server, otherwise we will not be able to request this endpoint anymore as it has alreasy reached rate-limit.
The text was updated successfully, but these errors were encountered: