Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to shallowmount with vue component #3011

Closed
Kishor-Kumar-Namdeo opened this issue Nov 26, 2018 · 2 comments
Closed

unable to shallowmount with vue component #3011

Kishor-Kumar-Namdeo opened this issue Nov 26, 2018 · 2 comments
Labels

Comments

@Kishor-Kumar-Namdeo
Copy link

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: '[email protected]',
password: 'test123',
confirm_password: 'test123',
name: 'unit test'
}
}
}
})
})
})


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

@Kishor-Kumar-Namdeo
Copy link
Author

@sodatea please comment on this issue....

@haoqunjiang
Copy link
Member

See: vuejs/vue-test-utils#1023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants