QUnit is a JavaScript unit-testing framework for checking whether functions produce expected results. Tests live separately from application code and import the functions under test. section 6.1 section 6.0
A basic test names a case, calls a function, and uses an assertion to compare the result with the expected value. This isolates small units of behavior and supports repeatable tests. section 6.1
Testing a function
QUnit.test('Test Find Person', function(assert) { const ssn = '444-44-4444'; const person = findPerson(ssn); assert.equal(person.ssn, ssn); }); section 6.1
QUnit is especially useful for functional code because predictable, modular functions are easier to test independently. Side effects and mutations make imperative code harder to test consistently. section 6.1 section 6.0
QUnit.test('Test Find Person', function(assert) {
const ssn = '444-44-4444';
const p = findPerson(ssn);
assert.equal(p.ssn, ssn);
});
Use the compact listing to inspect the structure of a QUnit test, including its test name, assertion object, function call, and equality check. section 6.1
QUnit can also work with Blanket.js to display statement-coverage results. Coverage reveals which code paths tests execute, although coverage differs between imperative and functional implementations. section 6.5
