小编김은솔*_*김은솔的帖子

vue test utils TypeError:无法解构“未定义”或“空”的属性“config”

我正在使用 vue test utils 进行简单的单元测试。但它不起作用。我不知道....帮帮我

我安装了这些东西.....

> $ npm i -D jest @vue/test-utils vue-jest jest-serializer-vue babel-jest babel-core@bridge

> $ npm i -D @babel/core @babel/preset-env
Run Code Online (Sandbox Code Playgroud)

我做了jest.config.js文件

module.exports = {
  moduleFileExtensions: [
    'vue',
    'js'
  ],

  moduleNameMapper: {
    '^~/(.*)$': '<rootDir>/src/$1'
  },

  modulePathIgnorePatterns: [
    '<rootDir>/node_modules',
    '<rootDir>/dist'
  ],

  testURL: 'http://localhost',

  transform: {
    '^.+\\.vue$' : 'vue-jest',
    '^.+\\.jsx?$' : 'babel-jest'
  }
}
Run Code Online (Sandbox Code Playgroud)

和测试/Parent.test.js

import { mount } from '@vue/test-utils'
import Parent from './Parent.vue'

test('Mount', () => {
  const wrapper = mount(Parent)
  expect(wrapper.html()).toBe('')
})
Run Code Online (Sandbox Code Playgroud)

但是 npm …

vue-test-utils

5
推荐指数
3
解决办法
1754
查看次数

标签 统计

vue-test-utils ×1