testing-library / vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
http://testing-library.com/vue
MIT License
1.07k stars 111 forks source link

feat: allow passing instantiated Vuex store #232

Closed blimmer closed 3 years ago

blimmer commented 3 years ago

As currently written, the store property passed to the render function must be StoreOptions, which is a plain Javascript object passed to new Vuex.Store() in the render function.

This is great for simple components and should definitely still be a supported option. However, it would be really useful for us to be able to pass a complex, instantiated Vuex store (generated by our common test helpers) as well.

This PR accomplishes this behavior by checking if the passed store is an instance of Vuex.Store and skipping the new Vuex.Store() call in that case.

If this seems reasonable, I can also update the API documentation in the other repository πŸ˜„ . Thanks for your time & consideration!

afontcu commented 3 years ago

Looks like there are some typing issues – probably due to the extended type for the store option? https://github.com/testing-library/vue-testing-library/pull/232/checks?check_run_id=2820969444#step:5:100

blimmer commented 3 years ago

Thanks @afontcu - I updated this PR and tested it on my fork. I'm a little surprised that StoreOptions and Store are interchangeable but, if the test suite is working properly, it looks like they are!

codecov[bot] commented 3 years ago

Codecov Report

Merging #232 (789f889) into master (4efca8a) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #232   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           99        99           
  Branches        33        33           
=========================================
  Hits            99        99           
Impacted Files Coverage Ξ”
src/render.js 100.00% <100.00%> (ΓΈ)

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update 4efca8a...789f889. Read the comment docs.

afontcu commented 3 years ago

Thank you for this! πŸŽ‰

github-actions[bot] commented 3 years ago

:tada: This PR is included in version 5.7.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 2 years ago

:tada: This PR is included in version 6.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: