Skip to content

Instantly share code, notes, and snippets.

@trodrigues
Created December 6, 2012 11:08
Show Gist options
  • Save trodrigues/4223742 to your computer and use it in GitHub Desktop.
Save trodrigues/4223742 to your computer and use it in GitHub Desktop.
testing AMD modules and mocking dependencies with buster.js and sinon
define(['dependency'], function(dependency){
buster.testCase('some test', {
setUp: function(done){
var self = this;
this.someStub = sinon.stub(dependency, 'method');
require(['moduleToTest'], function(ModuleToTest){
self.instance = new ModuleToTest();
});
},
"test something": function(){
self.instance.doWhatever();
assert.something();
},
tearDown: function(){
this.someStub.restore();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment