Unit testing involves writing small tests for individual units or functions of an application to ensure they work as expected. Tests should be written from the start of a project to prevent bugs and regressions. Unit tests allow for collaborative work by different contributors, help automate catching errors, and produce more reliable code by testing features as they are developed. While unit testing requires upfront effort, it saves work in the long run by reducing unexpected bugs that would otherwise be found by users. The testing framework QUnit can be used to write unit tests in separate .js files and run them from an index.html page.