javascript - TypeError: Falsy value found in plugins - Vue Unit Testing with Jest
问题描述
我刚刚开始通过Jest为我已经存在的项目编写测试用例。Vue.js
唯一有效的测试用例是 Hello World,它只检查数据是否正在呈现。
这是一个似乎不起作用的自定义规范。
我创建了一个FancyHeading.spec.js文件
import { shallowMount } from '@vue/test-utils'
import FancyHeading from '@/components/FancyHeading'
describe('FancyHeading', () => {
test('if logged in is false, do not show logout button', () => {
const wrapper = shallowMount(FancyHeading)
expect(wrapper.find('button').isVisible()).toBe(false)
})
test('if logged in, show logout button', () => {
expect(true).toBe(true)
expect(1 + 1).toBe(2)
})
})
对于以下组件:
<template>
<div>
<button class="btn" v-show="loggedIn">Logout</button>
</div>
</template>
<script>
export default {
name: 'fancy-heading',
data () {
return {
loggedIn: false
}
}
}
</script>
由于以下原因,测试用例无法运行:
FAIL tests/unit/FancyHeading.spec.js
● Test suite failed to run
TypeError: Falsy value found in plugins
at node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:15
at Array.map (<anonymous>)
at Function.normalisePlugins (node_modules/babel-core/lib/transformation/file/options/option-manager.js:162:20)
at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:239:36)
at OptionManager.init (node_modules/babel-core/lib/transformation/file/options/option-manager.js:373:12)
at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at compileBabel (node_modules/vue-jest/lib/compilers/babel-compiler.js:23:21)
at processScript (node_modules/vue-jest/lib/process.js:30:10)
我在这里想念什么?
解决方案
推荐阅读
- corda - CorDapp 在 CRaSH Shell 中工作,但 API 无法识别 CorDapp
- python - AWS-EMR 错误退出代码 143
- java - 将 java.sql.Timestamp 转换为 Java 8 ZonedDateTime?
- postgresql - 以 liquibase 格式从数据库中导出数据
- r - 如何使用 data.frame 中的因素进行操作?
- excel - 如何将两个相邻列的总和放入一个合并单元格(VBA)?
- python - 最小化生产能力和生产能力的界限
- python - 您是否需要存储旧数据以在 sklearn 中重新调整模型?
- java - Java:从不同类加载器中的类调用方法
- numpy - 从另一个数组索引中提取数组元素