This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('emit events when close-btn clicked', () => { | |
const closeBtn = wrapper.find('.close-btn'); | |
closeBtn.trigger('click'); | |
expect(wrapper.emitted().close.length).toBe(1); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('has blah class', () => { | |
expect(wrapper.contains('.blah')).toBe(true); | |
}); | |
// check multiple elements by verifying count | |
test('has blah classes', () => { | |
expect(wrapper.findAll('.blah').length).toBe(10); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount, createLocalVue } from '@vue/test-utils'; | |
import Vuex from 'vuex'; | |
import Component from './component'; | |
let wrapper; | |
let store; | |
let actions; | |
let mutations; | |
let state; | |
const localVue = createLocalVue(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
["env", { "modules": false }] | |
], | |
"env": { | |
"test": { | |
"presets": [ | |
["env", { "targets": { "node": "current" }}] | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount } from '@vue/test-utils'; | |
import Component from './component'; // name of your Vue component | |
let wrapper; | |
beforeEach(() => { | |
wrapper = shallowMount(Component, { | |
propsData: {}, | |
mocks: {}, | |
stubs: {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
verbose: true, | |
moduleFileExtensions: [ | |
"js", | |
"json", | |
"vue" | |
], | |
transform: { | |
".*\\.(vue)$": "vue-jest", | |
"^.+\\.js$": "<rootDir>/node_modules/babel-jest" |
NewerOlder