Open davidmoshal opened 3 years ago
Im experiencing the same issues.
I just switched from ts-jest
transformer to esbuild-runner/jest
or @swc-node/jest
.
Before I switched everything worked fine, but after the switch these errors popped up for every typescript-ioc
related call.
I noticed that other decorators were not working as well , for example I needed to adapt following decorator helper function:
from
export const isFunctionAsync = (fn: any): boolean => {
const string = fn.toString().trim()
return Boolean(string.match(/__awaiter/))
}
to
export const isFunctionAsync = (fn: any): boolean => {
const string = fn.toString().trim()
return Boolean(string.match(/__awaiter|async/))
}
This implies that the stringified function doesnt look the way it used to look. Maybe this is the same problem here as well
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:
Container.bind(IService).to(Service) new Vue({ router, render: (h) => h(App), }).$mount('#app');
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)