Skip to content

fix(runtime-utils): pass global directives to mountSuspended#960

Merged
danielroe merged 3 commits into
nuxt:mainfrom
joel-wenzel:patch-1
Oct 3, 2024
Merged

fix(runtime-utils): pass global directives to mountSuspended#960
danielroe merged 3 commits into
nuxt:mainfrom
joel-wenzel:patch-1

Conversation

@joel-wenzel

@joel-wenzel joel-wenzel commented Sep 30, 2024

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #959

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ x] 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Custom vue directives, typically added through a nuxt plugin, are not available in the testing environment.

For example the following plugin defines a custom uppercase directive:

export default defineNuxtPlugin(({ vueApp }) => {
  vueApp.directive('uppercase', {
    mounted: (el, binding, node) => {
      // ...impl code
    },
  })
})

However when running tests the below warning can be observed:

[Vue warn]: Failed to resolve directive: uppercase
  at <MountSuspendedComponent >
  at <MountSuspendedHelper>
  at <Anonymous ref="VTU_COMPONENT" >
  at <VTUROOT>
[Vue warn]: Failed to resolve directive: uppercase 
  at <MountSuspendedComponent > 
  at <MountSuspendedHelper> 
  at <Anonymous ref="VTU_COMPONENT" > 
  at <VTUROOT>

@danielroe danielroe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you 🙏

@danielroe

Copy link
Copy Markdown
Member

would it be possible to add a test?

@joel-wenzel

Copy link
Copy Markdown
Contributor Author

would it be possible to add a test?

@danielroe sorry - I looked at adding a test the other day and was running into some issues trying to import mountSuspended

@danielroe danielroe changed the title fix (mount suspended): register directives if any exist fix(runtime-utils): pass global directives to mountSuspended Oct 3, 2024
@danielroe

Copy link
Copy Markdown
Member

no worries at all!

@danielroe danielroe merged commit 73b8d7a into nuxt:main Oct 3, 2024
@github-actions github-actions Bot mentioned this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MountSuspended should consider any directives added to the vue app

2 participants