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 8938311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:35:44+00:00 2026-06-15T10:35:44+00:00

I am starting in node.js unit testing, and I have been investigating which was

  • 0

I am starting in node.js unit testing, and I have been investigating which was the most used framework for unit tests in node.js. I’d like to start with the most used framework just to makes things easier as there might be more information about it. According to many sites that could be Mocha.

While I understand this module for doing integration tests I don’t really know how to work with it by using feautures like stubbing dependencies. I have seen mocha doesn’t provide mock/stub functionalities, so I don’t really know how people usually deal with these problems.

So I’d like to know what modules are the most popular nowadays for doing unit tests, stubbing dependencies… A short example would be great.

Thanks

  • 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-06-15T10:35:45+00:00Added an answer on June 15, 2026 at 10:35 am

    The current suite of modules combined together in many node.js projects seems to be:

    • Mocha for the actual test harness itself
    • Chai for assertions
    • Sinon for mocking/stubbing

    All of these work both in node.js as well as the browser, which is important to many people including myself. There are many choices available as you might expect, although when it comes to mocking and stubbing I believe Sinon is clearly the current popular choice.

    Here’s a small example in coffeescript that uses all of these libraries. It tests that when you fill in the sign in form and submit it, your info is passed to the API properly.

    describe "UserSignInView.signIn", ->
      it "should submit the user credentials", ->
        sinon.spy _OT.api, "sendJSON"
        testUser =
          email: "test.user@othenticate.com"
          password: "password"
        $("#OT_signInForm .OT_email").val(testUser.email).change()
        $("#OT_signInForm .OT_password").val(testUser.password).change()
        $("#OT_signInForm .OT_signInButton").click()
        assert.ok _OT.api.sendJSON.called
        credentials = _OT.api.sendJSON.lastCall.args[0]
        assert.equal credentials.email, testUser.email
        assert.equal credentials.password, testUser.password
        options = _OT.api.sendJSON.lastCall.args[1]
        assert.equal options.url, "/othen/users/authenticate"
        assert.isDefined options.error
        assert.isDefined options.success
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting my node.js server like this: sudo NODE_ENV=production forever start -o out.log -e
I am just starting with node.js. I have done a little ajax stuff but
I'm starting with node.js and am making a simple MVC framework. So far, I've
I'd like to pass input from node into a commandline-based program I wrote. Starting
I'd like to execute a shell command starting a long-running script from node and
I have xml file nameed Hello as under with starting node as under: /
I'm starting with node expressjs framework and I came across this problem I can't
I am just starting ios development with IOS 5 and storyboards and would like
I am just starting node.js and I'm wondering why my small form is stopping
I am just starting out with node.js v.0.6.2 and Mac OSX Lion, and followed

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.