0.1.1 • Published 6 years ago

investigatr v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

investigatr

investigatr is a minimal, extensible JavaScript test framework that runs in the browser (node support coming soon). The main aim of investigatr is to allow testing without modification of existing code and fast setup of tests.

Basic Usage

First, install investigatr

npm install investigatr

Next, create my.spec.js and myTestRunner.html in the cloned folder. Our file structure will look like:

investigatr
  - node_odules
  - my.spec.js
  - myTestRunner.html
// my.spec.js
testGroup('Test Group Name', {
    data: {},
    tests: {
        "verify investigatr is working": function (data) {
            assertEquals(1, 1);
        },
    }
});
<!-- myTestRunner.html-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>investigatr test suite</title>
</head>

<body>
    <div class="investigatr">

    </div>
    <script src="./node_modules/investigatr/dist/investigatr.js"></script>
    <script src="./my.spec.js"></script>
    <script>
        investigatr.run();
    </script>
</body>

</html>

Open mytestRunner.html in a browser and you should see your test passing. For a more complicated example view the spec files in the tests folder.

By default investigatr outputs the results to a div element with the class of investigatr.

testGroup options

data | object | required

the data that should be set at the start of every test

tests | object | required

an object containing all the tests for this group. Keys are the test names and values should be functions.

tests: {
    "test name": function() {
        assertEquals(1,1);
    }
}

beforeEach | function(data) | optional

function to call before every test. Can be used to set up data etc.

investigatr options

investigatr allows options to be set with the init method.

example:

investigatr.init({
    output: false;
})

output | boolean

if output is set to false the render method on the renderer will not be called

renderer | instance of a class that implements a render method

Renderer is how the results will be renderer. It should be an instance of a class that implements a render method.

Extending investigatr

coming soon

Contributing

Running the tests

To run the tests simply clone this repository and open tests/testRunner.html. The tests use investigatr as a test framework.

License

This project is licensed under the MIT License - see the LICENSE.md file for details