Javascript - Test Framework

About

Test - Unit Test Framework (xUnit) in Javascript

A test framework is composed of two part that you can use separately:

Implementation Example

  • The function to test named plus1
function plus1(a){
    return a + 1;
}
  • The test function of the plus1 function
function test(then, expected) {
    results.total++;
    var result = plus1(then);
    if (result !== expected) {
        results.bad++;
        console.log("Expected " + expected + ", but was " + result);
    }
}
  • The run
var results = {
    total: 0,
    bad: 0
};
test(1, 2);
test(2, 4);
  • The result
console.log("Of " + results.total + " tests, " + results.bad + " failed, " +  (results.total - results.bad) + " passed.");

List

Documentation / Reference





Discover More
Javascript - Karma (Test runner)

Karma is a javascript test runner that permit to execute test code in multiple real browsers via phantomJs. Karma is not a testing framework, nor an assertion library. Karma just launches an HTTP server,...
Javascript Test - Runner

in Javascript. See also: Winner: Jest because: it's fully integrated in my IDE it supports React out of the box it can also test Typescript it forces you to not start a browser to test...
Nodeunit Run Configuration Intellij
Node - Nodeunit

Make sure that NODE_PATH environment variable points to the parent directory of nodeunit module. Create a test folder as a test source folder Optional: In Intellij, mark it as test dir. Create...
PhantomJS

itself is not a test framework, it's an headless browser. It is only used to launch the tests via a suitable test runner. : headless WebKit scriptable with a JavaScript API for...



Share this page:
Follow us:
Task Runner