Попытка модульного тестирования функций внутри экспортируемого модуля с помощью Jest
Модуль выглядит следующим образом:
export default {
errorNotification (title, text) {
Vue.notify({
group: 'max-fordham',
type: 'error',
title: title,
text: text
})
},
infoNotification (title, text) {
Vue.notify({
group: 'max-fordham',
type: 'info',
title: title,
text: text
})
},
successNotification (title, text) {
Vue.notify({
group: 'max-fordham',
type: 'success',
title: title,
text: text
})
},
warningNotification (title, text) {
Vue.notify({
group: 'max-fordham',
type: 'warning',
title: title,
text: text
})
}
}
Тест, который я пытаюсь написать,:
import notifications from '@/services/notifications.service'
describe('Notifications tests', () => {
test('successNotification should set title to title and text to text ', () => {
let title = 'test'
let text = 'test'
//let successNotification = jest.fn()
notifications.successNotification(title, text)
expect(title).toEqual('test')
expect(text).toEqual('test')
})
})
Когда я запускаю это, я получаю следующую ошибку:
Ошибка типа: _vue.default.notify не является функцией
СейчасНасколько я понимаю, ошибка из-за того, что я не издеваюсь _vue.default.notify
, однако я не уверен, как на самом деле это сделать. Некоторая помощь будет оценена.