Skip to content
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

docs: improve testing component examples #27138

Merged
merged 1 commit into from May 11, 2024
Merged

Conversation

michaelmcandrew
Copy link
Contributor

🔗 Linked issue

Resolves #27120.

Thanks @danielroe for the pointer on the import shortcut.

I made a PR with some related tweaks - hopefully improvements.

  • I removed the declaration of the Components and the associated Component type import since they are no longer necessary.
  • I split the first example in two since the comments indicate they are separate files.
  • I used the @ directory alias to do the app import (import App from '@/app.vue') but maybe there is another way?

Copy link

stackblitz bot commented May 9, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions bot added the 3.x label May 9, 2024
@danielroe danielroe changed the title Improve testing component examples to avoid auto import misunderstanding docs: improve testing component examples May 10, 2024
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

This looks great - just need to confirm it will pass twoslash type testing - it might need some more basic comments.

Also (tiny thing) we generally prefer the tilde alias in the docs.

// ---cut---
// tests/components/SomeComponents.nuxt.spec.ts
import { mountSuspended } from '@nuxt/test-utils/runtime'
import App from '@/app.vue'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import App from '@/app.vue'
import App from '~/app.vue'

// ---cut---
// tests/App.nuxt.spec.ts
import { renderSuspended } from '@nuxt/test-utils/runtime'
import App from '@/app.vue'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import App from '@/app.vue'
import App from '~/app.vue'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I updated the @s to ~s and gave it a conventional commit message and force pushed (which now that I have properly read the contribution docs I am thinking might not have been necessary since it'll use the PR title).

Anyhow, hopefully all good now. Thanks for your help. A nice smooth process :)

@danielroe
Copy link
Member

Thank you ❤️

@danielroe danielroe merged commit f465e4d into nuxt:main May 11, 2024
6 checks passed
@github-actions github-actions bot mentioned this pull request May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: improve testing component example to avoid auto import misunderstanding
2 participants