Skip to content

unable to shallowmount with vue component #3011

Closed
@Kishor-Kumar-Namdeo

Description

@Kishor-Kumar-Namdeo

Version

3.1.1

Reproduction link

jestjs/jest#7413

Node and OS info

yarn

Steps to reproduce

Hi, i am using @vue/cli-plugin-unit-jest : "^3.1.1" and when i run src/view/* component test script file then shallowMount working fine but when i run src/components/* component test script file then its show bellow error.

What is expected?

shallowMount work fine with component

What is actually happening?

not working

Hi, please help me to solve such issue. my component & test file content are below....

register.vue




    
        
            

REGISTER

Name Field should be minimum 3 letters

Enter valid email address

Password should be minimum 6 digit

Password and confirm password should be same

REGISTER

Already have an account? Log In

<script> import { required, minLength, maxLength, email, sameAs } from 'vuelidate/lib/validators' import { REGISTER_WITH_EMAIL_PASSWORD, UPDATE_USER_NAME, UPDATE_USER_PHOTO } from '../../../../resource/firebase' import EventBus from '../../../../helpers/event-bus' export default { name: 'Register', data () { return { user: { email: '', password: '', confirm_password: '', name: '' } } }, validations: { user: { name: { required, minLength: minLength(3), maxLength: maxLength(40) }, email: { required, email }, password: { required, minLength: minLength(6) }, confirm_password: { sameAsPassword: sameAs('password') } } }, methods: { registerUser () { this.$v.user.$touch() if (this.$v.user.$invalid) { return false } EventBus.$emit('pageLoading', true) REGISTER_WITH_EMAIL_PASSWORD({ email: this.user.email, password: this.user.password }, (data) => { // console.log(data) this.updateDetails() }, (error) => { EventBus.$emit('pageLoading', false) // console.log(error) this.$swal({ type: 'error', title: error.message, showConfirmButton: false, timer: 1500 }) }) }, async updateDetails () { let photo = process.env.VUE_APP_BASE_URL + '/images/default_user.png' await UPDATE_USER_NAME(this.user.name) await UPDATE_USER_PHOTO(photo) EventBus.$emit('pageLoading', false) this.$emit('changeModal', 'login') this.$swal({ position: 'top-end', type: 'success', title: 'Your Account created successfully.... Please Login', showConfirmButton: false, timer: 2000 }) } } } </script>

register.spec.js

import { shallowMount } from '@vue/test-utils'
import Register from '@/components/commons/modals/auth/Register.vue'

describe('Register', () => {
it('check login with email & password', () => {
console.log('dsfasfsd');
const wrapper = shallowMount(Register, {
data() {
return{
user: {
email: 'unittest@test.com',
password: 'test123',
confirm_password: 'test123',
name: 'unit test'
}
}
}
})
})
})


error while run test
screenshot_2018-11-26_18-01-48

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions