About test.js

This is Test JS, perfect for testing your html and javascript code. Link the b.js and the clsTest.js filesto your html file, where you want to run the tests.
The test report is either created in a pop up (new html page) or as a child element of your page.

Insert the following files in your html file:

Add the following script:

Done.

Now when you call 'test()' in our console (or another way), the tests will be excecuted and the results shown.

Start

See the following template


            

The script section starts with referencing the needed js files b.js and the clsTest.js. Then comes the explicit part, where first a new test object is created. This test object is our test manager that is passed to the test cases function. Wihtin the testcases function, the test object is passed to every test case, like an operator/manager that executes every test case by itself. The test object saves information about the excecuted tests within itself.

The testcases itself are defined in a separate JavaScript file, typically named testCases.js. This file contains the test cases function, which receives the test manager object and executes all your individual test cases. By keeping your test cases in a dedicated file, you maintain a clean separation between your test logic and your main application code.

Once the test cases have been performed the results can be printed. Sine T.js is pure javascript, there's no html file created on your file system. Everything happens in your browser

In this version, the tests run automatically when the page loads. You don't need to manually call the `test()` function from the console. The script at the bottom of the page initializes the test manager, executes the test cases, and displays the results as soon as the page is ready.

test cases

Next we have to write the test cases. You can set up the structure as you want. The only thing that needs to be considered is that the test varibale 'myTest' must be passed to each test.