How to Dependency Inject an Object with Cypress Component Testing #23842
-
When a component requires, for example, a logging service object that is dependency injected (DI), how is that component tested using Cypress Component testing? Consider:
How is Cypress accommodating DI parameters/objects for component creation? For completeness, here is the error we get when running our component test.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You would do it like so:
|
Beta Was this translation helpful? Give feedback.
-
I would like still to be able to interact with the service e.g. execute a function in it etc. I know its not ment for that using e2e tests but for component testing in my case it makes sence and I don't see any workaround cause they don't offer you the test bed to get services. |
Beta Was this translation helpful? Give feedback.
You would do it like so: