I have just started to write test cases for my already existing Vue.js project through Jest. The only test case that worked was Hello World in which it only checks for the if the data is being rendered or not. This is a custom spec which doesn't seem to be working.
I have created a FancyHeading.spec.js file
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)
})
})
For the below Component:
<template>
<div>
<button class="btn" v-show="loggedIn">Logout</button>
</div>
</template>
<script>
export default {
name: 'fancy-heading',
data () {
return {
loggedIn: false
}
}
}
</script>
The test case fails to run due to the following reason:
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)
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire