test injected tokenised provider not loaded on constructor #2660
Replies: 1 comment 11 replies
-
it seems the solution is to use export async function platformCreate(settings?: Partial<TsED.Configuration>): Promise<void> {
initDotEnv();
const mockDS = {
initialize: vi.fn(),
getRepository: vi.fn(),
};
registerProvider<DataSource>({
provide: SQLITE_DATA_SOURCE,
type: "typeorm:datasource",
useValue: mockDS,
});
await PlatformTest.create({
...settings,
envs,
});
} it's odd, but it works. if this is intentinal or not |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have no idea why this is happening or how to solve it.
consider thee following 3 injected deps:
and the repo is:
and finally the dao is:
as you can see, in
FileDao
i use tokenised injection ofSQLITE_DATA_SOURCE
.this works fine when starting the app as i do
registerProvider
:however, when i go to test the
RecordInfoSocket
class, i it will ALWAYS say that theSQLITE_DATA_SOURCE
inFileDao
is undefined.I have tried this in my
PlatformTest.create
method:However, this doesn't work and the injected
SQLITE_DATA_SOURCE
token is still undefined.I can't use
PlatformTest.injector.addProvider
because in order to do that,m the playform context needs to be created, and for that,FileDao
needs to not fail, and it does.For added context, the code actually fails in the constructor of
AbstractDao
thatFileDao
extends and passes it the repo.tl;dr. how do i get tonekised
SQLITE_DATA_SOURCE
working inPlatformTest.create
?Beta Was this translation helpful? Give feedback.
All reactions