-
Hi there 👋🏻 I hope you are well. Thanks for your job on this library. I am using this library along How I use it currently alongside head.tsimport { createHead } from '@unhead/vue';
export const head = createHead(); main.tsimport { head } from './composables/head';
app.use(head); any-component.vue<script setup lang="ts">
import { useHead } from '@unhead/vue';
useHead({
meta: [{ name: 'description', content: 'This is the best description ever' }],
});
</script> any-component.test.tsimport type { RenderOptions, RenderResult } from '@testing-library/vue';
import { render } from '@testing-library/vue';
import Component from 'path/to/components/any-component.vue';
import { head } from 'path/to/composables/head';
describe('any-component.vue', () => {
let mountOptions: RenderOptions;
beforeEach(() => {
mountOptions = {
global: {
plugins: [head],
},
};
});
it('my super test', () => {
render(Component, mountOptions);
// [...]
});
}); Do you have an idea of how to properly inject head and remove these warnings ? Thanks for your help 🙏🏻 Wish you a great day ☀️ |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi there 👋🏻 using 1.5.2 head.tsimport { createHead } from '@unhead/vue';
export const head = createHead(); main.tsimport { head } from './composables/head';
- app.use(head);
+ setHeadInjectionHandler(() => head) any-component.vue<script setup lang="ts">
import { useHead } from '@unhead/vue';
useHead({
meta: [{ name: 'description', content: 'This is the best description ever' }],
});
</script> any-component.test.tsimport type { RenderOptions, RenderResult } from '@testing-library/vue';
import { render } from '@testing-library/vue';
import Component from 'path/to/components/any-component.vue';
import { head } from 'path/to/composables/head';
describe('any-component.vue', () => {
let mountOptions: RenderOptions;
beforeEach(() => {
- mountOptions = {
- global: {
- plugins: [head],
- },
- };
+ setHeadInjectionHandler(() => head)
+ mountOptions = {};
});
it('my super test', () => {
render(Component, mountOptions);
// [...]
});
}); |
Beta Was this translation helpful? Give feedback.
-
Hey @smarlhens. Firstly, thank you for the nice words and detailed discussion :) It looks like you spotted my latest release, so well done on fixing it yourself without any docs! Sorry for the delay in getting back to you, wanted to make sure there was a good solution first. Wish you a great day as well 🌞 |
Beta Was this translation helpful? Give feedback.
Hi there 👋🏻
using 1.5.2
setHeadInjectionHandler
seems to be fixing the issue:head.ts
main.ts
any-component.vue
any-component.test.ts