This file contains 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
export function setGlobals() { | |
global.window.localStorage = { | |
setItem: (key, value) => null, | |
getItem: (key) => [], | |
}; | |
} |
This file contains 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
const $route = { | |
params: { | |
id: 15, | |
}, | |
}; | |
const wrapper = mount(ComplexComponent, { | |
mocks: { $route }, | |
}); |
This file contains 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('someComputedProperty should evaluate buzzwords correctly', () => { | |
const wrapper = mount(CoolCard, { | |
propsData: { | |
wow: 'wow' | |
} | |
}); | |
wrapper.setData({ | |
buzzword: 'Big Data' | |
}); | |
expect(wrapper.vm.someComputedProperty).toEqual('Big Data is very big'); |
This file contains 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('someMethod should add numbers together', () => { | |
const wrapper = mount(CoolCard); | |
expect(wrapper.vm.someMethod(1, 2)).toEqual(3); | |
}); |
This file contains 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
"overrides": [ | |
{ | |
"files": [ "**/*.test.js" ], | |
"rules": { | |
"quotes": [ 2, "single" ] | |
} | |
} | |
] |
This file contains 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
{ | |
"globals": { | |
"jest": true, | |
"expect": true, | |
"mockFn": true, | |
"config": true, | |
"afterEach": true, | |
"beforeEach": true, | |
"describe": true, | |
"it": true, |
This file contains 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 { mount } from '@vue/test-utils'; | |
import FakeComponent from '../components/FakeComponent.vue'; | |
describe('FakeComponent', () => { | |
test('it should display the right number of table rows', () => { | |
const wrapper = mount(FakeComponent); | |
expect( | |
wrapper.findAll('[data-test="fake-table-row"]').wrappers.length | |
).toBe(2); | |
}); |
This file contains 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 { mount } from '@vue/test-utils'; | |
import CoolCard from '../components/CoolCard.vue'; | |
describe('CoolCard', () => { | |
test('should render content correctly', () => { | |
const wrapper = mount(CoolCard); | |
expect(wrapper.find('[data-test="cool-card-div"]').text()).toEqual( | |
'hello I am a card :)' | |
); | |
}); |
This file contains 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
"env": { | |
"test": { | |
"plugins": ["transform-es2015-modules-commonjs"] | |
} | |
} |
This file contains 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
"jest": { | |
"moduleFileExtensions": [ | |
"js", | |
"vue" | |
], | |
"transform": { | |
"^.+\\.js$": "babel-jest", | |
".*\\.(vue)$": "vue-jest" | |
} | |
} |