-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing compatibility with NestJS #58
Comments
Hi @vinayak25, just a quick ping. This is quite blocking me as I'd like to publish my library for Intent with the right tests. If this is a no-go, I'll proceed without them. I just need to understand what can be done and what can I do to help. Thank you! |
Hey @alexandercerutti I am working on a testing framework for IntentJS. It's in the work right now, so for now you can ship your package without it. Let me know if you would need any help from my side |
I see. Thank you for the answer! I'll ship without tests and add them in the future. |
@vinayak25 if you are interested, here is the plugin I published for IntentJS, with a documentation in wikis. |
Hi @vinayak25, I was playing around with testing on the plugin I created.
I started by looking at the example code inside the sample app automatically cloned.
As there is no documentation on Intent website on how to build tests, I tried to give a look to NestJS documentation.
As the example code is pretty similar, I tried to follow the example it provided and adding both my Controller and my Service.
However, when
app.init()
happens, NestJS spits out the following error:Caution
An invalid controller has been detected. "RegistrationController" does not have the @controller() decorator but it is being listed in the "controllers" array of some module.
I started debugging both NestJS code and IntentJS code.
What I found is kind of weird to me: apparently the two libs
@Controller()
decorators seem to be incompatible each-other:@intentjs/core
sets the property@intentjs/controller_path
nest
looks for the propertypath
intent/packages/core/lib/rest/http-server/decorators.ts
Lines 22 to 27 in 92c4ee9
So, fixing it would be as easy as doing this (I already tried and it worked).
function ControllerMetadata(path, options) { return function (target) { Reflect.defineMetadata(constants_1.CONTROLLER_KEY, path || '', target); + Reflect.defineMetadata("path", path || '', target); Reflect.defineMetadata(constants_1.CONTROLLER_OPTIONS, options, target); }; }
But before opening a PR or whatever, I'd like to understand if this is intentional and why, or if you are expecting a different way to test controllers defined with
@Controller()
from@intentjs/core
that I don't know.In my opinion, making it compatible with Nest would be the best thing.
Let me know!
The text was updated successfully, but these errors were encountered: