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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:26:57+00:00 2026-06-17T06:26:57+00:00

Assertions provided by node.js assert for unit-testing are very limited. Even before I’ve written

  • 0

Assertions provided by node.js assert for unit-testing are very limited. Even before I’ve written the first test I was already creating a few of assertions as it was clear I will keep re-using them.

Could you recommend some good library of assertions to test for common javascript situations (object structures, objects classes, etc., etc.)?

Ideally it should integrate well with nodeunit (or, better, extend it’s assertions) – my assertions do not, I have to pass them test as an extra variable…

The only one I’ve seen is Chai. What could you say about it?

  • 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-17T06:26:59+00:00Added an answer on June 17, 2026 at 6:26 am

    I use my very own assertion library, node-assertthat. It’s specialty is its syntax which looks very fluent and (IMHO) is very readable (inspired by NUnit for .NET), e.g.:

    var actual = [...],
        expected = [...];
    
    assert.that(actual, is.equalTo(expected));
    

    Basically it works very well, but there are not too many asserts implemented yet. So whether it is “good” or not I won’t decide – that’s up to you.

    It makes use of a comparison library which provides things such as comparing objects by structure and some other nice things: compare.js.

    E.g., if you have to objects and you want to know if they are equal (by their values), you can do

    cmp.equal(foo, bar)
    

    or short as:

    cmp.eq(foo, bar)
    

    You can also compare objects by structure, e.g. check whether two objects implement the same interface. You could do this like

    cmp.equalByStructure(foo, bar)
    

    or short as:

    cmp.eqs(foo, bar);
    

    Again, I’ll let you decide whether it’s “good”, but at least I am quite comfortable with using both.

    PS: I know that StackOverflow is no place to advertise your own projects, but I think that in this case the answer forces me to do this, as the answer to ‘could you recommend’ is ‘my own tooling’ in this case as for ME it is the best fit. Please don’t consider this post as spam hence.

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

Sidebar

Related Questions

I would like to provide some custom Assert methods in my MSTest Unit Testing
The example on this page only shows Groovy assertions without parentheses. assert a !=
I have the following NancyFX unit test. I use the Shouldly assertion library to
I am new for Junit testing framework. Is it possible to test a flow
I have a unit test fixture in which I'm trying to test a ControllerAction
It seems that most XUnit testing frameworks provide assertions for the times when you
Some assertions in my code just started acting strangely, and I was wondering if
I noticed that static assertions in class templates are not triggered when instantiations are
I can't seem to get assertions working in my eclipse android project. I have
I have a certain set of assertions that I give to z3 which are

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.