October 2018
Intermediate to advanced
590 pages
15h 5m
English
The reason we need to test the data validation is to make sure there is validation in place and user input has been properly validated before being sent to the backend. Let's add the following test to RegisterPage.spec.js to verify that, when the value of the email address is invalid, the registrationService.register() method won't be invoked:
...import Vuelidate from 'vuelidate'import registrationService from '@/services/registration'...localVue.use(Vuelidate)...// Mock dependency registratioServicejest.mock('@/services/registration')describe('RegisterPage.vue', () => { ... it('should fail when the email address is invalid', () => { const spy = jest.spyOn(registrationService, 'register') wrapper.vm.form.emailAddress ...Read now
Unlock full access