0
votes

I have default jest.config.js but when i want run unit test i get an error message:

Validation Error: Preset @vue/cli-plugin-unit-jest/presets/typescript-and-babel not found.

I am using vue 2 with composition api plugin and typescript.

jest.config.js:

module.exports = {
  preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel'
}

example.spec.ts:

import { shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'

describe('HelloWorld.vue', () => {
  it('renders props.msg when passed', () => {
    const msg = 'new message'
    const wrapper = shallowMount(HelloWorld, {
      props: { msg }
    })
    expect(wrapper.text()).toMatch(msg)
  })
})
1
Do you have this plugin installed locally in your project?Sohel Aman
Yes i have it installed as dev dependencies.LukasGur

1 Answers

2
votes

I solved this problem with update jest plugin from: @vue/cli-plugin-unit-jest": "^3.12.1" to: @vue/cli-plugin-unit-jest": "^4.5.0"