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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:53:10+00:00 2026-05-12T10:53:10+00:00

I’ve been writing unit tests in strongly typed languages and I have a fair

  • 0

I’ve been writing unit tests in strongly typed languages and I have a fair good understanding about it. When writing unit tests in JavaScript to verify if certain functions are working properly in certain browsers I am back to the manual testing. I have no understanding of how it works. Because JavaScript is meant to close the gap between data and presentation and make it more interactive. And everything is happening within browsers and it’s more to do with UI. So I am assuming that if I were going to write a unit test I would write something like (in pseudo code):

run function A
check DOM if certain element has been created
  if not then fail
check if element is visible
  if not then fail
check for the content of that element
  if null then fail
etc…

Writing these tests seem like “hard coding” to me and what’s missing is that the tests wouldn’t be able to tell if it’s been rendered properly, it’s only doing the pure functional tests. So I am wondering if someone can explain to me what are the proper test procedures in JavaScript, how to do build automations and some general concepts in doing it. I was just looking at John Resig’s project testswarm but yet to figure out what it’s about. I am also reading about QUnit at the moment.

I am looking for some introductory materials on the concepts/practices that can me started. I am not looking for specific libraries or tools unless they have good introduction on the concepts.

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-05-12T10:53:10+00:00Added an answer on May 12, 2026 at 10:53 am

    This is definitely a confusing and dynamic area of web development right now. In my mind, there are a few important feature distinctions of JS testing:

    • pure unit tests, that test plain Javascript code. You can assert that a+b=3, or whatever. We’ve had only a few problem that fit into this category. When discussion options, there are lots of alternatives to the JSUnit (a JUnit port). They break down into TDD vs. BDD and naming choices within those categories.
    • Javascript + DOM tests. So much of the code written these days is about manipulating the DOM. eg. assertEqual('<a><div /></a>', $('div').wrap('a')); For DOM-based JS testing, you either need to move to in-browser testing, or use a library like env.js.
    • There are also mocking & stubbing (smoke), async and other helpers

    There are two places tests can run:

    • out-of-browser testing (generally faster to run, so they can be used in a TDD enviroment)
    • in-browser testing (slower, more complicated, but provide more accurate cross-browser test results)

    Selenium runs in-browser, so it is great for integration tests. If you have nothing else working, this is a good starting point. It’s been around for a few years and supports most popular browsers and languages. Watching a screencast like this might be helpful. And this documentation might give you a flavor of what the tests would look like. There are also quite a few other tutorials and screencasts around, but many of them get bogged down in the technical doodoo you don’t care about, so you have to be selective.

    Finally, here’s an example from blue ridge, which is a collection of tools pulled together for out-of-browser testing (and manual in-browser test) for Rails:

    Screw.Unit(function() {
        describe("Your application javascript", function() {
            it("accesses the DOM from fixtures/application.html", function() {
                expect($$('.select_me').length).to(equal, 2);
            });
        });
    });
    

    This is a single test using an rspec-like syntax test test that a couple elements are there. Hope this helps!

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

Sidebar

Related Questions

I have been writing unit tests using NUnit and Moq with my Silverlight code
I have been having a query regarding writing unit tests for web methods which
Two questions about unit tests. I've been writing unit tests for a while, however
I've been building a framework and writing unit tests in GHUnit. One of my
I'm writing unit tests for a module in a small Javascript application. In order
This question about unit tests sparked another thing that's been bothering me. I've gone
I’ve been writing some tSQLt database unit tests (via Red Gate SQL Test) on
I've been following Apple's documentation on writing unit tests for the iPhone, and out
Recently I've been tasked with writing and running unit tests in C# for a
I'm writing unit tests for an MVC web app, and I've been getting null

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.