🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@jenkins-cd/js-test

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jenkins-cd/js-test

NPM module containing JavaScript utilities for testing Jenkins CI modules.

latest
Source
npmnpm
Version
1.2.3
Version published
Maintainers
6
Created
Source

Jenkins JS Test

This package provides some test utilities.

Install Package:

npm install --save-dev @jenkins-cd/js-test

Also see js-modules and 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 = require("@jenkins-cd/js-test");

var JENKINS_PAGE = '<html><head resURL="/jenkins"></head><body><div id="divOnPage">Bootstrap is everywhere</div></body></html>';

describe("bootstrap3.js", function () {

    it("- test", function (done) {
        jsTest.onPage(function() {
            var bootstrap3 = require("../js/bootstrap3");
            var $bootstrap = bootstrap3.getBootstrap();

            expect($bootstrap('#divOnPage').text()).toBe('Bootstrap is everywhere');
            
            done();
        }, JENKINS_PAGE);
    });
});

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 = require('../../../src/js/utils/mathUtil');

Using requireSrcModule, the above code would be:

var jsTest = require("@jenkins-cd/js-test");

var mathUtil = jsTest.requireSrcModule('utils/mathUtil');

NOTE: This is integrated with js-builder. It will resolve the module being required based on src/test builder configuration.

Examples

See the examples in js-samples, especially step-07-jsdom-tests and step-08-zombie-tests.

FAQs

Package last updated on 26 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts