README
utiny
Tired of installing 25 dependencies, just to run unit tests? utiny is the essence of unit testing in JavaScript.
It allows unit testing of ES6 modules without additional dependencies, right in your browser.
Demo: http://shaack.com/projekte/utiny/test/
Works like this
- Create a
test/index.html
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tests</title>
</head>
<body>
<script type="module">
import {TestMyModule} from "./TestMyModule.js"
TestMyModule.run()
</script>
</body>
</html>
- Create test classes extending
Test
, in this caseTestMyModule.js
. Functions namedtest[…]
will be executed automatically, when you calltest/index.html
in your Browser.
import {Test} from "../src/utiny/Test.js"
export class TestMyModule extends Test {
testThisWillNotFail() {
Test.assert(true)
}
testThisWillFail() {
Test.assertEquals(42, 1 + 2)
}
}
Result
The result will look like this:
Configuration
const props = {
htmlOutput: true, // enable HTML output
consoleOutput: true, // enable output via console
onyl: undefined /*
set as String to run one specific test only,
set as array to run multiple specific tests in the test class,
leave as undefined to run test[…] functions in the test class
*/
}
TestMyModule.run(props)