question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functional Testing without starting server

See original GitHub issue

How do I send a request to KOA app without starting the server

I want to avoid app.listen(port)

I am looking for something like

yield koaApp.sendRequest("POST", "/login/user", {
   username : "svsf",
   passwd : "XXXX"
}, {
    someHeader: "header Value"
})

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
PlasmaPowercommented, Oct 25, 2016

Yeah listen(0) seems to be how a lot of testing frameworks do it under the hood. Not sure there’s any downside to it.

if i start server using app.listen(port) it blocks and jasmine is not able to execute test cases ?

app.listen certainly does not block, I think the problem is elsewhere.

To answer your original question though, I think this might work:

app.callback()(req, res);

(you’ll probably want to store app.callback() somewhere after you’ve added in the middleware, calling that calls compose on the middleware)

4reactions
corporatepiyushcommented, Nov 19, 2016

app.callback() works like a charm. Many thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing a web application without web server - Stack Overflow
To completely test the web application without tomcat or jetty server, the web server behavior has to be simulated.
Read more >
The different types of testing in software | Atlassian
Functional tests focus on the business requirements of an application. They only verify the output of an action and do not check the...
Read more >
3 ways to write function tests for Liberty - IBM Developer
There are many ways to write function tests for WebSphere Liberty and Open ... (or another IDE) without first manually starting the server....
Read more >
Testing - hapi.dev
To this end, Hapi includes the ability to test routes without having to actually start a server, completely avoiding the time overheads and...
Read more >
A Node.js Guide to Actually Doing Integration Tests - Toptal
Your software isn't fully tested until you write integration tests for it. While unit tests help ensure that functions are properly written, integration ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found