Skip to content

Test cases cannot use test and it at the same time #921 #922

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

Closed
Rudy24 opened this issue Aug 15, 2018 · 5 comments
Closed

Test cases cannot use test and it at the same time #921 #922

Rudy24 opened this issue Aug 15, 2018 · 5 comments

Comments

@Rudy24
Copy link
Contributor

Rudy24 commented Aug 15, 2018

Version

1.0.0-beta.24

Reproduction link

https://vue-test-utils.vuejs.org/zh/guides/#%E6%B5%8B%E8%AF%95%E5%BC%82%E6%AD%A5%E8%A1%8C%E4%B8%BA

Steps to reproduce

test('Foo', () => {
  it('fetches async when a button is clicked', (done) => {
    const wrapper = shallowMount(Foo)
    wrapper.find('button').trigger('click')
    wrapper.vm.$nextTick(() => {
      expect(wrapper.vm.value).toBe('value')
      done()
    })
  })
})

What is expected?

describe('Foo', () => {
  it('fetches async when a button is clicked', (done) => {
    const wrapper = shallowMount(Foo)
    wrapper.find('button').trigger('click')
    wrapper.vm.$nextTick(() => {
      expect(wrapper.vm.value).toBe('value')
      done()
    })
  })
})

or 

describe('Foo', () => {
  test('fetches async when a button is clicked', (done) => {
    const wrapper = shallowMount(Foo)
    wrapper.find('button').trigger('click')
    wrapper.vm.$nextTick(() => {
      expect(wrapper.vm.value).toBe('value')
      done()
    })
  })
})

What is actually happening?

test('Foo', () => {
  it('fetches async when a button is clicked', (done) => {
    const wrapper = shallowMount(Foo)
    wrapper.find('button').trigger('click')
    wrapper.vm.$nextTick(() => {
      expect(wrapper.vm.value).toBe('value')
      done()
    })
  })
})

There is a problem here, you can't use test and it at the same time, these two methods can't be used at the same time.

@eddyerburgh
Copy link
Member

eddyerburgh commented Aug 15, 2018

Yes you're right, there's a mistake. These should just use test like the rest of the documentation.

It should be refactored to this:

test('fetches async when a button is clicked', (done) => {
    const wrapper = shallowMount(Foo)
    wrapper.find('button').trigger('click')
    wrapper.vm.$nextTick(() => {
      expect(wrapper.vm.value).toBe('value')
      done()
    })
})

@Rudy24
Copy link
Contributor Author

Rudy24 commented Aug 15, 2018

@eddyerburgh
pls update documentation of vue-test-utils,tks

@Rudy24
Copy link
Contributor Author

Rudy24 commented Aug 16, 2018

@eddyerburgh can i make a PR for this ?

@eddyerburgh
Copy link
Member

Yes, please :)

@eddyerburgh
Copy link
Member

Hi @Rudy24 are you able to make a PR with this change?

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

No branches or pull requests

2 participants