Aurelia 2, DI How do you tackle mocks and scopes (like request)?

So I have 2 big problems I’m going to have to sort out before I’m done migrating from Tsyringe to Aurelia DI. That’s mocks and request scope, since this isn’t a browser based application, I presume all of the prebuilt stuff is out the door. I might be able to learn from it though if I knew what code to look at.

Mocks: The problem as I see it is, I have an OrderService which injects an OrderRepository, for a test I want to mock OrderRepository while testing the service (better examples are when OrderService relies on a 3rd party API). I have no idea right now how to achieve this, especially not in a way that makes the mocks only active for a given test suite.

I think Request Scope mostly speaks for itself, is the best way a child container? is there a better way to register objects with that child than doing so with child.register(...)?

1 Like

Can you give some pseudo code example what you have tried so far?