Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7570393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:24:50+00:00 2026-05-30T15:24:50+00:00

I have just downloaded mocha.js and have ran some basic tests with expect.js to

  • 0

I have just downloaded mocha.js and have ran some basic tests with expect.js to ensure that it’s working properly.

But what about testing responses in my node application at a specific url? I.e how do I test what response I get from navigating to /users for instance?

Using Expresso, mocha.js’s predecessor, I could do assert.response(server, req, res|fn[, msg|fn]) and test the response.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:24:51+00:00Added an answer on May 30, 2026 at 3:24 pm

    This is one thing that I love about Node.js/Javascript, doing this sort of thing is simple once you got the hang of it.

    In short, you run your server code and then actually use either Request or Superagent to make these HTTP requests. I personally prefer Superagent because of it’s automatic JSON encoding, but be careful, the docs are out of date and incorrect, YMMV. Most people choose Request.

    Simple Mocha Example using Request:

    describe('My Server', function(){
        describe('GET /users', function(){
            it("should respond with a list of users", function(done){
                request('http://mytesturl.com/users', function(err,resp,body){
                    assert(!err);
                    myuserlist = JSON.parse(body);
                    assert(myuserlist.length, 12); 
                    done(); 
                }); 
            }); 
        });
    });
    

    Hopefully that helps. Here is a sample of my Mocha (CoffeeScript) testing using this style with complete detailed examples: https://github.com/jprichardson/logmeup-server/blob/develop/test/integration/app.test.coffee Oh ya, it also is using Superagent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just downloaded Sparx Enterprise Architect 7.5 but unfortunately I am not able
I just downloaded a website template that is in a .PSD form. I have
I am confused about js file of jQuery which one i have downloaded just
I just downloaded the SWT examples from the Eclipse site but I have a
Just downloaded IE9 and pulled up a webproject i have with an IHttpHandler that
I just downloaded Xcode 4.1 that comes with 4.3.2 sdk. I have built a
I have just started working with Symfony. I downloaded the sf_sandbox and I am
I have just downloaded SQL Server 2005 express edition from here: To be used
I have just downloaded the flexigrid and examples and tried to execute. In the
I'm new to Apex and have just downloaded Eclipse to get to work Eclipse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.