Well, I was just starting to go into Browserify, and I had a problem writing jasmine tests. Basically, I have an idea about a trunk that has a nested representation in it, now for testing purposes, I obviously do not want to test the socket representation here, since it is tested with its own unit tests. What I want to do is just drown it out, check that it gets called with the right one
So, I have the following
nestedView = require('./nested_view.coffee')
module.exports = class MainView extends Backbone.View
initialize:(collection, attr)->
NestedView = if _.isUndefined(attr.Stub) then NestedView else attr.Stub
@nested_view = new NestedView()
Then in my tests:
it "Tests my nested view", ->
Stub = sinon.stub()
@mainview = new MainView(collection:@collection, {SV:Stub})
expect(Stub).toHaveBeenCalledOnce()
While this works, it is a bit unpleasant, since I need to add code to my script only to run the tests.
Does anyone know a better approach?