Answer the question
In order to leave comments, you need to log in
How to write unit tests without (or replacing) dependencies?
Good evening.
This is my first time writing a unit test, so please don't throw tomatoes at me =)
There is "example.spec.js" (taken from Hello Word)
import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import PageMain from '@/components/PageMain.vue'
describe('PageMain.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(PageMain, {
propsData: { msg }
})
expect(wrapper.text()).to.include(msg)
})
})
<template>
<f7-page>
<CardInfo :article="$locale({i: 'CONTENT.main'})"></CardInfo>
</f7-page>
</template>
//...
import Vue from 'vue'
import App from './App.vue'
import Localize from 'v-localize'
Vue.use(Localize)
let localize = Localize.config({
default: 'ru',
available: ['ru', 'en'],
fallback: '?????',
localizations: {
'en': EN,
'ru': RU
}
})
new Vue({
localize,
render: h => h(App)
}).$mount('#app')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question