setUp() and tearDown()
JsUnit supports setUp() and tearDown(). That is, if you define a function called setUp() in a Test Page, it is called before each test is run. If you define a function called tearDown(), it is called after each test. For an example, see the Test Page called jsUnitSetupTearDownTests.html which comes with JsUnit.
There are two important differences here between JUnit and JsUnit:
setUpPage()
JsUnit supports another kind of setUp function called setUpPage(). setUpPage() is called once on each Test Page before any Test Functions are called. setUpPage() can be a useful place to place script that needs to execute after the page is loaded but before any Test Functions are called, when setUp() is not appropriate (setUp() is called before every Test Function). setUpPage() is especially useful for the asynchronous loading of data documents.
If you implement setUpPage in your Test Page, you need to set the value of a variable called "setUpPageStatus" to "complete" when your function is finished. JsUnit then knows your function is done, and proceeds to execute the page.