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
fn.default check for transpiled modules #61
Conversation
More info in issue #60
Can you add a unit test for this? |
I'm not very familiar with unit testing in general. But would something like this suffice? test('should return "default" function from ECMAScript module', t => {
t.plan(1)
const plugin = {
default: () => {}
}
try {
fp(plugin)
t.pass()
} catch (e) {
t.is(e.message, 'fastify-plugin expects a function, instead got a \'object\'')
}
}) or are you looking for something more in-depth? |
that would work, yes! |
also, linting is failing. |
Co-Authored-By: nurdism <craigbett@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@Ethan-Arrowood can you confirm this would work well with ts as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you copy-paste your new unit test into the test.ts
file, it will throw an error. A basic fix to this is to add | { default: fastify.Plugin<HttpServer, HttpRequest, HttpResponse, T>}
to line 15 in fastify-plugin.d.ts
. Otherwise LGTM 👍
More info in issue #60