I am trying to unit test updating the meta content of a Vue & Quasar page using the useMeta
component supplied by Quasar
My test is as follows, I have a UseMetaComponent
mock vue component, that gets created within a mock App
component. The UseMetaComponent
does load, as 'Component Added' is output by the wrapper.html()
console log.
However, the meta tags are not updated. I have confirmed that this code does function properly in a browser.
installQuasarPlugin();
const UseMetaComponent = {
name: 'UseMetaComponent',
template: `
<div>Component Added</div>
`,
setup() {
useMeta({
title: 'New Title',
meta: {
description: {
name: 'description',
content: 'test',
},
},
});
},
};
const App = {
components: {
UseMetaComponent,
},
template: `
<!DOCTYPE html>
<html>
<head>
<title>Initial Title</title>
</head>
<body>
<div id="q-app">
<use-meta-component />
</div>
</body>
</html>
`,
};
describe('QuasarMetaHandler', (): void => {
const wrapper = mount(App);
console.log(wrapper.html());
it('defaults title Site Name', (): void => {
const title = document.getElementsByTagName('title');
console.log(title);
});
});
Is there a way to test updating the meta components?
from How to unit test updating meta content in Vue Quasar Meta component with Jest
No comments:
Post a Comment