Skip to content

StubModule.js - Stub AMD module dependencies for testing purposes when using the dojo AMD loader.

License

Notifications You must be signed in to change notification settings

tkmunzwa/StubModule

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status StubModule.js

A method for mocking AMD dependencies when testing JavaScript modules that are loaded with the Dojo AMD loader.

Inspired by this stackoverflow question and testr.

Open tests/spec/SpecHello.js for a demo.

Setup

StubModule.js can be loaded like any other AMD module.

When you want to stub a module:

it('this is a demo', function (done) {
    var stub = {};
    stubModule('path/to/module', {'path/to/dependency': stub}).then(function (StubbedModule) {
        var testObject = new StubbedModule();
        // tests/assertions
        done();
    });
});

Other Notes

Run bower install and npm install before running the tests. Run the tests by running grunt travis.

This will not work for the ESRI JSAPI prior to version 3.4. However, at 3.4 they turned on the dojo-undef-api has tag and it works great!

About

StubModule.js - Stub AMD module dependencies for testing purposes when using the dojo AMD loader.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%