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.

How to mock/spy an imported function in Angular unit testing

Let's say i have an angular 6 component with a method test which returns some value: import { doSomething } from './helper'; @…

javascript angular unit-testing mocking spy
C# is there a a spying framework like mockito for .NET 3.5?

I used to have a very convenient spying framework in java called Mockito. It allows you to mock some of …

c# .net mocking spy spying
What is the difference between jest.fn() and jest.spyOn() methods in jest?

I am writing the Unit test cases for my react project and using jest and enzyme for writing test cases. …

reactjs mocking jestjs spy
stubbing process.exit with jest

I have code that does something like function myFunc(condition){ if(condition){ process.exit(ERROR_CODE) } } How can I test …

javascript mocking jestjs spy
Mockito - internal method call

I have a class called Availability.java and have two methods. public Long getStockLevelStage() { //some logic getStockLevelLimit(); } public Long getStockLevelLimit() { …

java unit-testing junit mockito spy
Jest onSpy - expected mock function to have been called

I'm struggling with using spyOn as part of testing my utils.js module. I've tried various methods and approaches but …

javascript unit-testing mocking jestjs spy
Mockito mock a method but use its parameters for the mocked return

There is a method public Content createChild(String path, String contentType, Map<String,Object> properties) I'd like to …

java unit-testing mockito spy
How to spy on a class property arrow function using Jest

How can I spy on a class property arrow function using Jest? I have the following example test case which …

reactjs jestjs enzyme spy
How to validate the return value when calling a mocked object's method

Using Mockito, is there a way to spy() on an object and verify that an object is called a given # …

java mocking mockito spy
How do I mock an exported typescript function in a jasmine test?

I'm trying to mock a function exported from a typescript file in a Jasmine test. I expect the following to …

unit-testing typescript jasmine mocking spy