SimonTest icon indicating copy to clipboard operation
SimonTest copied to clipboard

How to generate the **jasmine.createSpyObj** instead of **Stubs**

Open ravi-mone opened this issue 6 years ago • 1 comments

Guys, This is not a code related question, but since it is related to unit testing and angular, posting here

I am using this extension https://marketplace.visualstudio.com/items?itemName=SimonTest.simontest

But when genearting the test cases

enter image description here

It generates the Stubs for the services, Is there any way possible to make it generate the jasmine.createSpyObj

Have gone through the site, https://simontest.net/ not have not found any info, can you guys please help me on how to generate the jasmine.createSpyObj instead of Stubs

ravi-mone avatar Jul 16 '20 18:07 ravi-mone

Hi there. Moving the spies up the chain prevents optimizations like caching and parallelization. It also promotes the anti-pattern of sharing state/spies between tests.

The best practice is to stub the dependencies and then spy on them in the tests. See this example.

ManuelDeLeon avatar Jul 16 '20 18:07 ManuelDeLeon