Closed telion2 closed 3 years ago
Hi @telion2
Thank you for opening an issue.
This is more an issue with the CLI than with vue-test-utils, but as I have an idea about the reason, let's answer it here.
You are trying to use Jest 27 which is currently not supported by the CLI. We're working on landing the support for Jest 27 (see this PR https://github.com/vuejs/vue-cli/pull/6627 if you are interested), but this still needs more work.
My advice would be to stick to jest 26 (and ts-jest, and babel-jest 26)
Ho and I realize you're using Vue 2! If you're still on v2, you should be using @vue/test-utils v1, and vue-jest v4.See the documentation here https://vue-test-utils.vuejs.org/
Setting these versions right should solve your issues!
Subject of the issue
I wanted to run my first test with Vue 3, Typescript and VTU.
So I ran vue add unit-jest and npm install --save-dev @vue/test-utils
This created an example Test file. ( I had to point to a different component, but that isn't the issue.)
The first thing I encountered was:
So ok I wanted to install babel-jest then: npm install -D babel-jest But it failed because of conflicting Library vue-jest:
So ok maybe npm is stupid, so I installed babel-jest anyways with: npm install babel-jest --legacy-peer-deps Installation successful, but wenn running the tests:
This is an Error I couldn't find a solution for. Now Granted I am new to a few things like Vue 3 and Typescript. I made everything else work though, except making jest understand vue files and VTU tests.
Here is my package.json:
The npm script I use for the unit tests is: "test:unit:coverage": "vue-cli-service test:unit --verbose --coverage "
the jest.config.js I tried:
The jest Config I want to use but didn't work either:
This Config would fail because of:
My tsconfig.json:
Expected behaviour
When I run vue add jest-unit, then I want VTU to work with jest, typescript and Vue 3. When importing a .vue file, no Error is thrown.
Actual behaviour
Various Errors are thrown from mainly Babel, which can't figure our how to deal with Vue 3 typescript files.
Possible Solution
No Idea.