-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
feat(imports): Add minimal stubs useAuth and useAuthState imports #611
Conversation
WHne nuxt-auth module is disabled all #auth imports were failing. For mocking and testing this presented a situation which was impossible to handle properly. This commit adds a stub for these imports on the client side when the module is disabled, opening a way to mock the modules properly.
Hi @peterbud 👋 Thank you for your contribution! I think this is a really nice change, especially for testing suits! Do you think we may want to go one additional step and allow mocking of the composables? This way you could integrate e2e tests in a nicer way! |
I think mocking would be possible, but I'm not sure what additional step you mean. Could you pls clarify? |
I wrote a lengthy comment on how we handle mocking stubs inside of our internal applications here: #596 (comment) I also quickly touched on what would need to be done, to properly add mocking into our module. |
Thanks for the great summary at the other issue. I think that mocking setup would be best covered by adding it to the playground/example. In this PR I don't see it feasible to add a mocking infrastructure, as this PR is focusing on ensuring that there is some stubs to import when the module is not enabled. |
Hi @peterbud 👋
Sounds good! I wanted to let you know that I will upstream this PR to another colleague. Code wise I approve the changes, however I wanted to check with him, if this is how he would handle the |
@peterbud Could you please fix TS errors (simply add |
Done |
from: resolve('./runtime/composables/stub/useAuthState') | ||
} | ||
]) | ||
} |
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.
I believe you need to do a
if (!options.isEnabled) {
return
}
before step 6?
Otherwise you end up adding runtime plugins and middleware, is this intended?
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.
Look at line 157 pls.
@peterbud Could you please elaborate why this PR was closed? |
Due to lack of progress. For 4 months there was no traction with this PR. I understand if maintainers are busy. |
When
nuxt-auth
module is disabled (isEnabled=false
) all#auth
imports were failing. For mocking and testing this presented a situation which was impossible to handle properly. This commit adds a stub for these imports on the client side in case thenuxt-auth
module is disabled, opening a way to mock the modules properly without worrying the missing imports.Contributes to #454 #552 #596.
Checklist:
#
)