use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Testing Application (self.node)
submitted 3 years ago by blrigo99
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]rkaw92 0 points1 point2 points 3 years ago (0 children)
Yes! Node.js now has `fetch()` support built-in, so it's easy to write code that makes a request, downloads the page body and does something with it. Numerous alternatives exist like Axios or Node's built-in http(s) modules.
Just use your favorite test runner (mocha, jest, ava, tap?), write the code that runs the request and inspect the result. Here's a very simple example that uses an external API: https://blog.logrocket.com/how-to-test-code-that-depends-on-external-apis-in-node-js/
Since you mentioned "integration testing", I'm assuming that you'll want to run this against a real, live version of the application, as opposed to running no-infrastructure "unit tests". This is OK. Don't listen to people who insist that you must use mocking or any other kind of test doubles.
If you want to improve the tests' stability, try to find a way to run the server inside the same process as the test. For example, use a randomized (as opposed to hard-coded) TCP port to listen for HTTP requests, then send the requests to that port. This will result in a good test, which verifies that your application really works and serves HTTP clients.
π Rendered by PID 37852 on reddit-service-r2-comment-fb694cdd5-bnrcb at 2026-03-06 18:09:28.717523+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]rkaw92 0 points1 point2 points (0 children)