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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:19:22+00:00 2026-05-31T19:19:22+00:00

I am just getting started with JS Unit Testing and am trying out qUnit.

  • 0

I am just getting started with JS Unit Testing and am trying out qUnit.

When my JS executes (via it’s init() function) it grabs some nodes from the page which are required for the JS to run properly.

Currently my qUnit test is failing before it even starts because it doesn’t find those nodes in the test html file.

I’m not using jQuery in my JS at all (no framework).

I’ve done some looking around that implies I should load an iframe with my page onto the test.html page. I would then need to replace document with iframe.document or something similar, right?

Is that possible? How would I do that so my document.getElementById() doesn’t fail. It sounds like I need to set the context of the local test.html the same as the context of the iframe (window, document etc wise, at least, so it can reference the same nodes).

Any thoughts?

  • 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-31T19:19:23+00:00Added an answer on May 31, 2026 at 7:19 pm

    Yes as far as I know, the document nodes you mention are test data. The QUnit unit-test.html page contains a <div id='qunit-fixture' which is where your your test data stuff should be.

    So far I’ve had a good time with QUnit testing pure JS that is completely decoupled from the UI, the unit tests help with the separation too.

    However, for something more UI related you might want to take a look at how JQuery UI uses QUnit. See the accordion widget unit tests

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

Sidebar

Related Questions

I'm getting started with unit testing and trying to do some TDD. I've read
I'm just getting started with learning about Unit testing (and TDD in general). My
I'm just getting started with Knockout JS and with QUnit for doing unit tests
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
I'm currently in the process of getting started with unit testing and mocking for
Just getting started with jQuery, and I've had some success so far. I've created
I'm just getting stated with boost-test and unit testing in general with a new
Just some days ago I started looking into a unit test framework called check,
I've started working with Qunit to do unit testing on my code, but am
Just getting started with OpenFrameworks and I'm trying to do something that should be

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.