We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi There.
I'd like to write unit tests for my Vue3 SFC components in my fastify-vite app. I tried to use:
My jest.config.json looks like
module.exports = { moduleFileExtensions: ['js', 'json', 'vue'], testEnvironment: 'jsdom', transform: { '^.+\\.js$': 'babel-jest', '^.+\\.vue$': '@vue/vue3-jest' } };
And my copyright.spec.js file looks
copyright.spec.js
import {shallowMount} from '@vue/test-utils'; import Copyright from '../../../pageComponents/base/copyright.vue'; describe('Page components / Base / Copyright', () => { it('should have correct text', () => { const copyrightText = `My copyright text`; const wrapper = shallowMount(Copyright); expect(wrapper.text()).toContain(copyrightText); }); });
When I run tests, I see an error
TypeError: (0 , _vue.createElementVNode) is not a function
Could you please recommend me, how to fix it ? Maybe you have a working example, how to write tests for Vue3 components in fastify-vite apps ?
Thank you.
The text was updated successfully, but these errors were encountered:
I'd probably do something like this when testing SSR with Vue
import { createSSRApp, h } from 'vue' import { renderToString } from '@vue/server-renderer' it('should have correct text', async () => { const app = createSSRApp({ setup() { return () => h(Copyright) } }) const text = await renderToString(app) expect(text).toContain(`My copyright text`) })
Sorry, something went wrong.
FYI https://test-utils.vuejs.org/guide/advanced/ssr#Testing-Server-side-Rendering
No branches or pull requests
Prerequisites
Issue
Hi There.
I'd like to write unit tests for my Vue3 SFC components in my fastify-vite app.
I tried to use:
My jest.config.json looks like
And my
copyright.spec.js
file looksWhen I run tests, I see an error
TypeError: (0 , _vue.createElementVNode) is not a function
Could you please recommend me, how to fix it ? Maybe you have a working example, how to write tests for Vue3 components in fastify-vite apps ?
Thank you.
The text was updated successfully, but these errors were encountered: