Organizing Test Layers and Mocks in TypeScript for Unit Tests
for unit tests, how would you organise your test layers?
I started by defining the
should I instead define my test layers in my test files, more or less like you would do with "normal" code where I would have multiple classes that implements my interface:
or are there other patterns?
I like how you can do it with go with mocks, specifically the
I started by defining the
testLayer as a static method on my service, but if I have some tests where I want to have a different behaviour I obviously can't update the testLayer without modifying the behaviour of other tests.should I instead define my test layers in my test files, more or less like you would do with "normal" code where I would have multiple classes that implements my interface:
class PolicyRepoMockSuccess implement PolicyRepo , class PolicyRepoMockEmptyResponse implement PolicyRepo and so on.or are there other patterns?
I like how you can do it with go with mocks, specifically the
mockery lib where I can define the implementation for one of the methods in the test: