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

Unit tests raise errors with exit code 3221225725 on Windows #1781

Closed
ryo-utsunomiya opened this issue Jan 4, 2019 · 2 comments
Closed

Unit tests raise errors with exit code 3221225725 on Windows #1781

ryo-utsunomiya opened this issue Jan 4, 2019 · 2 comments

Comments

@ryo-utsunomiya
Copy link

ryo-utsunomiya commented Jan 4, 2019

Versions

  • vee-validate: 2.1.5
  • vue: 2.5.21
  • Node: 10.14.1

Describe the bug

On Windows, a Vue component test using VeeValidate raise errors with exit code 3221225725. I'm wondering if this is misuse of vee-validate in unit test or vee-valdiate issue.

My test code is:

import VeeValidate from 'vee-validate';
import { expect } from 'chai'
import { shallowMount, createLocalVue } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'

const localVue = createLocalVue();
localVue.use(VeeValidate);

describe('HelloWorld.vue', () => {
  it('renders props.msg when passed', () => {
    const msg = 'new message'
    const wrapper = shallowMount(HelloWorld, {
      propsData: { msg },
      localVue,
    })
    expect(wrapper.text()).to.include(msg)
  })
})

To reproduce

https://github.com/ryo-utsunomiya/poc-vee-validate-stack-overflow
This repository contains a sample Vue application with vee-validate, mocha and vue-test-utils.

You can reproduce the problem with following commands:

  1. git clone https://github.com/ryo-utsunomiya/poc-vee-validate-stack-overflow
  2. cd poc-vee-validate-stack-overflow
  3. yarn install
  4. yarn test:unit

When I run yarn test:unit on my Windows PowerShell, console output looks like this:

image

Expected behavior
The test passes without warnings/errors.

@logaretm
Copy link
Owner

logaretm commented Jan 7, 2019

Make sure to use sync: false in mounting/shallowMounting options when testing with vee-validate, vee-validate relies heavily on asynchronous rendering, so it wouldn't play nice with vue-test-utils synchronous behavior until vuejs/vue-test-utils#1062 is merged.

const wrapper = shallowMount(HelloWorld, {
  propsData: { msg },
  localVue,
  sync: false
});

Bonus tip: use flush-promises after triggering validation (via model change or event dispatch or test-utils trigger helper), since validation happens asynchronously.

@logaretm logaretm closed this as completed Jan 7, 2019
@ryo-utsunomiya
Copy link
Author

Setting sync: false perfectly worked. Thanks, you saved my day!

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

No branches or pull requests

2 participants