Skip to content

Two independent tests connected via Vuex #1337

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
AlexanderShushunov opened this issue Oct 30, 2019 · 5 comments
Closed

Two independent tests connected via Vuex #1337

AlexanderShushunov opened this issue Oct 30, 2019 · 5 comments

Comments

@AlexanderShushunov
Copy link

Version

1.0.0-beta.29

Reproduction link

https://github.com/AlexanderShushunov/test-vuex-error

Steps to reproduce

There are two test in repo. They just mount ComponentUnderTest.
For each tests I created a vuex-store.
ComponentUnderTest has a tamplate

  <div>
    <Init />
    <div v-if="flag" />
  </div>

Init component has created hook, which mutate flag.

Run test (npm run test)

What is expected?

There are no errors

What is actually happening?

TypeError: Cannot read property '$scopedSlots' of undefined

Errors can be different. It depends on template.

If I delete one test, another will pass.

If I replace created hook for mounted in Init tests will pass.

I do not use flag in v-if tests will pass.

@AlexanderShushunov AlexanderShushunov changed the title Two independent test connected via Vuex Two independent tests connected via Vuex Oct 30, 2019
@8simsim8
Copy link

8simsim8 commented Nov 1, 2019

V: 1.0.0-beta.29
The same problem

@AlexanderShushunov
Copy link
Author

Seems my issue has the same root with #1130

@8simsim8
Copy link

8simsim8 commented Nov 3, 2019

thank

@vvanpo
Copy link
Contributor

vvanpo commented Nov 3, 2019

As the linked issue explains, setting sync: false in the mount options will side-step this issue.

I can reproduce this issue without @vue/test-utils:

test('Vue-only sync', () => {
  let error = null

  Vue.config.async = false
  Vue.config.errorHandler = e => {
    error = e
  }

  const vm = new Vue({
    ...ComponentUnderTest,
    store: createStore()
  }).$mount()

  expect(error).toBe(null)
  // Failure:
  //     Expected: null
  //     Received: [TypeError: Cannot read property '$scopedSlots' of undefined]
})

So the bug clearly lies somewhere in Vue.js' sync behaviour. But as @eddyerburgh mentioned in the linked issue, sync behaviour is going away in both Vue and @vue/test-utils, so I imagine this won't get fixed in the meantime.

@AlexanderShushunov
Copy link
Author

@vvanpo , thx for example.
I added it in me repo https://github.com/AlexanderShushunov/test-vuex-error

I think this issue is not actual any more.

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

3 participants