using jasmine / spyOn to mock properties on an object

45 views
Skip to first unread message

Denisa Bokar

unread,
Jan 25, 2019, 11:40:23 AM1/25/19
to Jasmine

Is it possible to mock some properties on an object using Jasmine .spyOn()?  Basically, imagine I have a Page object that has titledeliveryTime and status that I want to mock it such that I just have to set the title propertytitle = 'test' ; the other two properties can have any value as are not relevant for my testing scenario. Why? 


Some test fake code would be:

spyOnProperty(page, "title").and.returnValue(test);


This would be equivalent to C# / Moq as:

mock.Setup(foo => foo.Name).Returns("bar");
Reply all
Reply to author
Forward
0 new messages