Comments (3)
Hello @jkrall
I had to change your test because isn't a normal container execution.
it("should inject service w/ async factory", async () => {
// GIVEN
class Test {
constructor(public type: string) {}
}
const TokenAsync = Symbol.for("MyService");
registerProvider<Test>({
provide: TokenAsync,
type: "test:async",
deps: [],
useAsyncFactory() {
return Promise.resolve(new Test("async"));
}
});
@Injectable()
class Parent1 {
@Inject(TokenAsync)
test: Test;
}
@Injectable()
class Parent2 {
@Inject(TokenAsync)
test: Test;
}
const injector = new InjectorService();
await injector.load() // PlatformTest.create() and PlatformExpress.bootstrap() always calls .load method to resolve async provider first.
const parent1 = await injector.invoke<Parent1>(Parent1);
const parent2 = await injector.invoke<Parent2>(Parent2);
expect(parent1.test).toBeInstanceOf(Test);
expect(parent2.test).toBeInstanceOf(Test);
});
Probably your unit test isn't correctly written :)
I let you close this issue
See you
from tsed.
Thanks @Romakita — appreciate the review and fix/resolution — closing this!
from tsed.
🎉 Are you happy?
If you appreciated the support, know that it is free and is carried out on personal time ;)
A support, even a little bit makes a difference for me and continues to bring you answers!
from tsed.
Related Issues (20)
- [BUG] DI resolves `alias` tokens non-deterministically HOT 4
- [BUG] @Nullable decorator does not work with unions of various objects HOT 3
- [BUG] MultipartFile doesn't show file input in Swagger HOT 1
- FormData property not available from BodyParams in a Middleware HOT 17
- [BUG] Invoke Error in platform-serverless on SQS event HOT 2
- [BUG] New implementation of "nullable" decreases the accuracy of ajv errors. HOT 4
- [BUG] @Integer annotation is no more taking into model when used with @Nullable(Number) HOT 12
- [BUG] TypeError in JsonDeserializer when handling Array of Maps HOT 9
- Run BullMQ workers $onReady? HOT 1
- [ERROR] [TSED] - TypeError: Cannot read properties of undefined (reading 'paramType') HOT 2
- Feat: Disable axios behavior HOT 23
- Option to disable cache control when caching endpoints
- [BUG] adding optional path paramater duplciates the endpoint in swagger HOT 3
- [Bug] micromatch dependency vulnerable to CVE-2024-4067 HOT 3
- [BUG] Unexpected "export" statement in ES module "PlatformLogMiddlewareSettings.js" HOT 7
- [BUG] Failed to install package @tsed/testcontainers-mongo HOT 2
- Support for computed fields in prisma plugin? HOT 8
- [BUG] jest tests fail starting from 7.80.0 HOT 6
- [BUG] Unexpected 'style' property when referencing an enum
- [V8] Roadmap
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tsed.