Closed a-c-m closed 2 days ago
Can't you try running tsc
over those spec files and then just node --test
? if this works, then it's not related with nestjs at all
Sorry I don't follow - jest works fine, it's node test which fails and I'm running tsc before the node test example?
Node's built-in TS transpilation doesn't support emitting metadata, hence, DI and anything metadata-related won't work as expected.
Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the # 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.
Is there an existing issue for this?
Current behavior
When running a simple test that uses createTestingModule, the dependencies are not injected, if the test is run using node:test, instead they are left undefined - so the test fails.
Similar code using jest works fine.
I've provided both for comparison.
Minimum reproduction code
https://codesandbox.io/p/sandbox/nestjs-createtestingmodule-nodetest-psylr8
Steps to reproduce
npm install
npm run test-jest
npm run test-node
Expected behavior
The DI system should still work with node:test - or we need to warn people.
Package
Other package
No response
NestJS version
No response
Packages versions
Node.js version
No response
In which operating systems have you tested?
Other
Originally raised on discord - https://discord.com/channels/520622812742811698/1305581785991614625/1305581785991614625