mercredi 26 avril 2017

Mocking and changing dependencies values in jasmine testcase

i recently started learning how to write unit test case using jasmine for my angular project.

i was writing test for my service and facing a problem

describe 
     var servicename;
     beforeEach
         load module
         mock data for some dependency x

     beforeEach
         take service in servicename using injector

     testcase 1
         check some assertion by calling method on servicename
         mock data for same dependency x to some other value
         check some assertion by calling method on servicename

i am not sure how i can change the value of mock data in testcase , please let me know how i can achieve this and if you have any other better way to do this

i can achieve this by writing 2 describe for different mock data but i don't want to do that

Aucun commentaire:

Enregistrer un commentaire