LukasGur
LukasGur

Reputation: 361

Jest error: "preset @vue/cli-plugin-unit-jest/presets/typescript-and-babel not found"

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)
  })
})

Upvotes: 2

Views: 5909

Answers (1)

LukasGur
LukasGur

Reputation: 361

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"

Upvotes: 5

Related Questions