Skip to content
This repository

Add instance mocks #37

jamesarosen opened this Issue December 15, 2010 · 1 comment

2 participants

James Alexander Rosen Davis W. Frank
James Alexander Rosen

I'd like to be able to mock out an object created via new. Perhaps something like

var i = new Image();
i.src = '/some_url';

or maybe

mockClass(Vehicle, 'Car');
var c = new Vehicle.Car();

I might also imagine being able to access the original definition of the "class" (function) via StubbedFunction.originalDefinition.

Davis W. Frank

Your latter example can be done with jasmine.createSpyObj - you can create an Object with a bunch of spies as functional properties. We do this a lot in our testing.

Your "instance" interface looks interesting. Why not test-drive the concept and see if you can get some traction?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.