Jenkins JS Test
This package provides some test utilities.
Install Package:
npm install --save-dev jenkins-js-test
Also see jenkins-js-modules and jenkins-js-builder.
onPage
This utility allows you to test some content using jsdom (a lightweight "headless" browser).
Here's an example from the Twitter Bootstrap Framework lib.
var jsTest = ; var JENKINS_PAGE = '<html><head resURL="/jenkins"></head><body><div id="divOnPage">Bootstrap is everywhere</div></body></html>'; ;
Note the call to
done();
. This is a Jasmine "thing". It marks the end of an async test flow.
requireSrcModule
This utility makes it a bit easier to load the modules under test.
Without using requireSrcModule
, tests would need to load source modules in an ugly/brittle path
(like in the above Bootstrap example) e.g.
var mathUtil = ;
Using requireSrcModule
, the above code would be:
var jsTest = ; var mathUtil = jsTest;
NOTE: This is integrated with jenkins-js-builder. It will resolve the module being
require
d based on src/test builder configuration.
Examples
See the examples in js-samples, especially step-07-jsdom-tests
and step-08-zombie-tests
.