You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks a lot for this project! I love the idea of having testable examples right on top of your functions.
I tried to get it to work with promises and I was surprised how easy it is to integrate new features like that (although it took me a while to get started, I guess the documentation could be a little clearer about how to write and use custom handlers). Anyway, thats what I came up with in order to test functions that return promises:
(Btw, just in case somebody struggles getting started with custom handlers as well, here is my package.json scripts configuration):
I had to export the function that I wanted to test, otherwise I would get "promiseFn is not defined". So my first question is: Does that mean that you can only test functions that you make public by either exporting them directly or wrapped inside an exported object?
For the case that everything works fine, this works great! But if the expected result varies from the actual output, I get a weird error message (saying "Passed" in red letters). But at least it tells me that the test failed.
First of all, thanks a lot for this project! I love the idea of having testable examples right on top of your functions.
I tried to get it to work with promises and I was surprised how easy it is to integrate new features like that (although it took me a while to get started, I guess the documentation could be a little clearer about how to write and use custom handlers). Anyway, thats what I came up with in order to test functions that return promises:
(Btw, just in case somebody struggles getting started with custom handlers as well, here is my package.json scripts configuration):
autodoc-helpers/autodoc-helpers.js:
autodoc-helpers/autodoc-promise-resolve.js:
autodoc-helpers/autodoc-promise-reject.js:
Now, I can write tests like this:
I had to export the function that I wanted to test, otherwise I would get "promiseFn is not defined". So my first question is: Does that mean that you can only test functions that you make public by either exporting them directly or wrapped inside an exported object?
For the case that everything works fine, this works great! But if the expected result varies from the actual output, I get a weird error message (saying "Passed" in red letters). But at least it tells me that the test failed.
console output:
So my second and main question is: How do I get autodoc to display an error message that makes sense?
And one last thing:
While testing the error cases of my functions, I noticed that it is quite easy to do as long I know exactly what the error looks like:
But as soon as the error is dynamic, I had to do some weird unpacking which seems a little unintuitive to me.
Does anyone have an idea how to solve this more elegantly?
One last question: Is this project still active and do you still think it is a good idea to write tests and documentation in this way?
Looking forward to your response,
Jesse
The text was updated successfully, but these errors were encountered: