You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<template>
<div>App</div>
</template>
<script lang="ts">
import { Component, Vue } from"vue-property-decorator";import { Inject } from"typescript-ioc";import { IService } from"./services";@Component()exportdefaultclassAppextendsVue { @Inject service1:IService// this works in browser, but fails in tests service2:IService=Container.get(IService) // this works in browser and also in tests}
</script>
However a test which wraps the App component fails:
import"reflect-metadata";import{Container}from"typescript-ioc";import{IService,Service}from"../../src/service";import{mount}from"@vue/test-utils";importAppfrom"../../src/App.vue";describe("TS_IOC specs",()=>{it("should return correct instances",()=>{Container.bind(IService).to(Service);// this succeeds, ie: the instance exists in the container:consta=Container.get(IService)// but this fails:constwrapper=mount(App)});});
Error message is: TypeError: Invalid type requested to IoC container. Type is not defined.
So, I'm curious, the instance and type exits in the container, but the wrapper doesn't find it.
Yet the App runs fine outside the test.
Why would this fail: @Inject service:IService
but this passes: service:IService = Container.get(IService)
The text was updated successfully, but these errors were encountered:
Nice library, works great with VueJS components, but fails when the components is wrapped and mounted for testing!
ie: Given a service, a main.ts and an App.vue component, everything works fine:
However a test which wraps the App component fails:
Error message is: TypeError: Invalid type requested to IoC container. Type is not defined.
So, I'm curious, the instance and type exits in the container, but the wrapper doesn't find it.
Yet the App runs fine outside the test.
Why would this fail:
@Inject service:IService
but this passes:
service:IService = Container.get(IService)
The text was updated successfully, but these errors were encountered: