Why SJTest? Very easy-to-use browser-based and/or command line testing.
Tests are defined and run within a normal html page, just like any other javascript. Here is a simple example:
<html>
<head>
<!-- You don't need jQuery or Bootstrap, but if they're present, we use them for nicer output. -->
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<!-- SJTest.js (please download your own copy) -->
<script src='https://rawgithub.com/winterstein/SJTest/master/SJTest.min.js'></script>
</head>
<body>
<script>
SJTest.run({name:'HelloWorld',
easyTest: function() {
assert(1+1 == 2);
},
failingTest: function() {
assert(false, "Well that was never going to work");
}
});
</script>
</body>
</html>
Try it now: HelloWorld.html?SJTest=on
SJTest=on
to the url, or in the page with <script>SJTest.on = true;</script>
Then just view your html page in any modern browser
phantomjs SJTest.js MyTestFile.html.
See the JSDoc or examples for details.
SJTest.run()
SJTest.runScript()
SJTest.runScriptFromUrl()
Example: Let's run some of SJTest's own tests here & now:
In the page, we have: <script>SJTest.runScriptFromUrl()</script>
Then the url can inject the test scripts: ?SJTest=test/SJTestTest.js
SJTest.runTest()
SJTest.runTest()
using waitFor()
See the JSDoc or examples for details.
See These handy functions are both in the SJTest namespace, and exported to global
(unless you set SJTest.expose=false
).
assert()
match()
assertMatch()
isa()
waitFor()
str()
Email:
Phone: +506 22907872
Rohrmoser, 10109
San José, Costa Rica
map
Email:
Twitter: @winterwellassoc
127 Rose Street Lane South
Edinburgh, EH2 3DT
map