Introducing Jester. Jester is a JavaScript unit tester based around GNOME’s Gjs JavaScript engine. I wrote it because I needed a stand alone tester for testing non-DOM JavaScript code in my AMQP Bindings (kamaloka-js). I also wanted to learn the ins and outs of Gjs and GLib Introspection while making it relevant to my friends in the GNOME Community. By utilizing a separate run time for non-DOM code I hope to encourage the separation of browser and generic JavaScript code for the sake of reuse across browser and desktop platforms.
Jester has a couple of components and can be used indirectly or directly by Gjs applications. The first component is the jester standalone application which can load and run a JavaScript file from the command line. Use this to integrate with test workflows such as make check or to simply test out some quick JavaScript. The second component is the jester.js module which can be loaded directly in a Gjs application. This module contains the Test class which is used to write unit tests.
Here is a simple example of how to use Jester:
test.js
const Jester = imports.jester;
let test = {
testExample: function() {
this.assertEquals(1, 1, "This test should always pass");
this.assertEquals(1, 2, "This test should fail");
}
}
this.info("Jester Example");
let test_suite = new Jester.Test({"Simple Test": test});
test_suite.run();
To run this code you would enter this on the command line:
jester test.js
Home Page: http://live.gnome.org/Jester
0.1 Tarball: http://live.gnome.org/Jester?action=AttachFile&do=view&target=jester-0.1.tar.bz2
Git:
- anonymous – git://git.gnome.org/jester
- commit access – ssh://USERNAME@git.gnome.org/git/jester
Since kamaloka-js is built on top of js.io, I have create a patch for js.io which makes the importer work when used with Jester.
[read this post in: ar de es fr it ja ko pt ru zh-CN ]