Skip to content

Instantly share code, notes, and snippets.

View jamesoshea's full-sized avatar

James O'Shea jamesoshea

  • Berlin
View GitHub Profile
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default (getters, actions) =>
new Vuex.Store({
modules: {
basket: {
namespaced: true,
const $route = {
params: {
id: 15,
},
};
const wrapper = mount(ComplexComponent, {
mocks: { $route },
});
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');
test('someMethod should add numbers together', () => {
const wrapper = mount(CoolCard);
expect(wrapper.vm.someMethod(1, 2)).toEqual(3);
});
"overrides": [
{
"files": [ "**/*.test.js" ],
"rules": {
"quotes": [ 2, "single" ]
}
}
]
{
"globals": {
"jest": true,
"expect": true,
"mockFn": true,
"config": true,
"afterEach": true,
"beforeEach": true,
"describe": true,
"it": true,
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);
});
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 :)'
);
});
<template>
<div
class="vte__cool-card"
data-test="cool-card-div"
>
hello I am a card :)
</div>
</template>
<script>
"env": {
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
}