Top "Spy" questions

A spy is XUnit pattern where you replace the original implementation with a test double to capture the calls on the object.

Mockito spy method not working

I'm in trouble with mockito.spy method. I'm recently arrived on a "old" project and my first task is to …

java mocking mockito spy
How to test that a function has been called after an event was fired?

There is custom event fired in the FooView .. // views/foo_view.js this.trigger("something:happened"); The associated FooController binds …

javascript asynchronous jasmine dom-events spy
Reset call on Jasmine spy does not return

I'm using a Jasmine (2.2.0) spy to see if a certain callback is called. Test code: it('tests', function(done) { var …

javascript jasmine spy jasmine2.0
How to use Jasmine spies on an object created inside another method?

Given the following code snippet, how would you create a Jasmine spyOn test to confirm that doSomething gets called when …

javascript testing jasmine spy
Mockito + Spy: How to gather return values

I got a class using a factory for creating some object. In my unit test I would like to access …

java mockito spy
How to spyOn a static class method with Jasmine

I have a class with a static method that I want to test in Jasmine. I understand that static methods …

javascript class static jasmine spy
How to spy on window.scrollTo in Jest?

I got a very simple react component with following functionallity: componentDidMount() { window.scrollTo(0, 0) } It seems that you cannot do something …

javascript unit-testing mocking jestjs spy
Using @Spy and @Autowired together

I have a Service Class with 3 methods, Service class is also using some @Autowired annotations. Out of 3 methods, I want …

java spring testing autowired spy
expected a spy but got undefined?

Trying to get my head around jasmine spies, this is what my test looks like: $scope.switchTurns = function () { $scope.playerTurn = !$…

angularjs tdd jasmine karma-jasmine spy
TypeError during Jest's spyOn: Cannot set property getRequest of #<Object> which has only a getter

I'm writing a React application with TypeScript. I do my unit tests using Jest. I have a function that makes …

reactjs unit-testing jestjs spy spyon