busterjs/buster — Issue #26: Stubbing requirejs
Author: johlrogge
Created: 2011-12-14 07:51:23+00:00
State: open

Just thought of a complimentary approach to the one described in #15.

If there was a requirejs extension for buster that would do this:

1. create two functions in global scope
* define(deps, body)
* require(deps, body)

Then buster has full control over which modules are loaded and could if necessary rewrite paths etc. Internally it would probably be wise to delegate to requirejs somehow since requirejs has a lot of plugins and stuff that would be a pain to emulate properly (I guess...). The merits of this approach I think is:

1. buster would know when everything is loaded since it is in the drivers seat
2. buster could allow the testwriter to declare something different than the real thing to be returned for a named module

buster.moduleStubs({"server/queue", function(element) {...emulate queue...}});

Totally insane?