vue-unit | Component testing utilities for Vue.js | Unit Testing library

 by   wrseward JavaScript Version: v0.3.0 License: MIT

kandi X-RAY | vue-unit Summary

kandi X-RAY | vue-unit Summary

vue-unit is a JavaScript library typically used in Testing, Unit Testing, Vue applications. vue-unit has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Component testing utilities for Vue.js
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              vue-unit has a low active ecosystem.
              It has 215 star(s) with 12 fork(s). There are 6 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 4 open issues and 6 have been closed. On average issues are closed in 5 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of vue-unit is v0.3.0

            kandi-Quality Quality

              vue-unit has 0 bugs and 0 code smells.

            kandi-Security Security

              vue-unit has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              vue-unit code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              vue-unit is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              vue-unit releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed vue-unit and discovered the below as its top functions. This is intended to give you an instant insight into vue-unit implemented functionality, and help decide if they suit your requirements.
            • Helpers
            Get all kandi verified functions for this library.

            vue-unit Key Features

            No Key Features are available at this moment for vue-unit.

            vue-unit Examples and Code Snippets

            No Code Snippets are available at this moment for vue-unit.

            Community Discussions

            QUESTION

            Vue Unit Testing: How to test complex components with props, vuex store, watchers, getters etc
            Asked 2020-Feb-17 at 23:53

            I have a question about unit testing (Jest) within a vue app - I guess it is rather an architectural question, but maybe specific code examples could also help me out.

            I have sketched out a more or less complex setup of vue components from my app. They are still simplified but I guess they should help to describe the situation.

            (PDF Attachment for those preferring non-pixel data :)

            I have a Wrapper which has three child components:

            • Search (Input field to search on Map)
            • List (List of stores, represented also as markers on map)
            • Map (Google Map itself)

            I would really like to write some unit tests for this, but it seems so super tedious to setup those tests, so that I doubt that this is the way to do it.

            It starts with the way I load the google maps API: The wrapper loads it asynchronously, sets API key etc. As soon as the google map API is loaded it passes it down to the children.

            Of course the map only really starts to load, create and display markers, as soon as google is present and I can use new this.google.maps.Map() for example.

            Even if I would like to test some methods of the Map component, I have to provide an actual google object, because otherwise the whole init process in mount() fails. It can't make a map.

            So do I have to load the actual google's map API in my tests? Or could I somehow skip mounting the map but still test a few isolated methods?

            Further you can see that my Map watches a getter from the vuex store: Whenever the searchCoordinates set by Search change in my vuex store, I want to execute some functions (for example center my map to the new search coordinates or remove a current location marker if the search did not return valid searchCoordinates).

            How could I somehow break down the interlinking between these components, but still write good and helpful tests, which help me to guarantee that the app does what it is supposed to do?

            I know that I can use a vuex store within my tests (Medium article about vuex testing). But still I feel like the whole app is so much inter-connected that doing actual unit testing – testing one small piece at a time – is impossible. It seems like that I would have to mount not only Map alone, but also the other components and a vuex store with actual data, to really write bulletproof tests.

            A few other examples, where I struggle:

            • In my mounted() I subscribe to an action with this.$store.subscribeAction((action) => {... - of course $store is undefined in my tests. Should I mock it?
            • As I said I am watching a getter: This throws errors like TypeError: Cannot use 'in' operator to search for 'searchCoordinates' in undefined. Would I have to mock all the getters as well? If so: what remains to be tested? If I mock (~=leave away) all the vuex stuff, it seems to me, that testing becomes useless...

            But maybe I am mistaken here. Also I am quite new to unit testing, so any hints are very welcome. Thank you very much in advance. I hope somebody has some valuable input. All those examples (even in books like Vue.js - up and running) are always broken down to very simple and understandable examples, but on the other hand don't really reflect real-life apps...

            Cheers

            ----- Edit:

            I got a needs more focus vote by someone. So I try to sum up simple and small questions:

            Summary of Questions

            1. Does somebody have a general input on how to test larger and more complex vue applications?
            2. Is there a way to test a component with a google map (or a component that is relying heavily on any third party code)
            3. Is mocking getters, store and actions a good idea in this case? (I have my doubts there).
            4. For testing watched properties from the vuex store, I read in this thread that mapState should be mocked. (in my case probably my getters). Does this make sense to mocke those getters in my case?
            5. Is it best practice to simplify as many things as possible in an tested component (for example, I started to override some methods, which failed (the one including google map initiation) to just get my test up and running:
            ...

            ANSWER

            Answered 2020-Feb-17 at 23:53

            After diving deeper into this question I realized one thing: If one has such a complex situation like described above, unit testing is probably not the right tool for this!

            In this case end to end testing also called integration testing would be much more suitable for the job.

            Because what I actually want to test is, that all the different component react in the right way, if something is changed/triggered and so on, I need to see the whole picture.

            If I go back to my example I want to see that the map changes if the search input registers a change and so on.

            I ended up integrating a few tests for this by using a headless browser googles puppeteer, opening the webpage, filling in a search query and then search the DOM for reliable changes in the map for example.

            Unfortunately I did not have the time to really go into detail with the testing on this one because of budget restrictions, but I got an idea of how this should be approached.

            My initial ideas of mocking a store etc. would require so much work which would be nothing else than building a big mock which resembles the rest of the app around a unit test, that it would be downright stupid to do that. With integration tests I use this already built app around my test, but I have the advantage of being able to test everything in sync!

            I personally also think that integration tests are much more powerful than unit tests, because they illuminate the parts of an application that are not so easy to grasp by a developer and will throw errors if one part of the application is changed and the other fails to function as desired.

            If somebody has more to add, I am still very glad to hear opinions on that matter.

            Cheers

            Source https://stackoverflow.com/questions/58922748

            QUESTION

            Vue.js unit testing best practice
            Asked 2019-Feb-17 at 17:06

            It's a general question. but i am curious to ask: there are many packages for vue js unit testing.

            which one would be best practice or recommended for enterprise project?

            ...

            ANSWER

            Answered 2018-Dec-06 at 12:31

            These are not comparable, as each of them serve a different purpose.

            From documentation of each of these libraries:

            vue-test-utils

            Vue Test Utils is the official unit testing utility library for Vue.js.

            vue-jest

            ... To teach Jest how to process *.vue files, we will need to install and configure the vue-jest preprocessor.

            cypress-vue-unit-test

            A little helper to unit test Vue components in the open source Cypress.io E2E test runner

            If you have no preference and looking for a place to start, then definitely start with official documentation: Choosing a test runner

            Source https://stackoverflow.com/questions/53650733

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install vue-unit

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/wrseward/vue-unit.git

          • CLI

            gh repo clone wrseward/vue-unit

          • sshUrl

            git@github.com:wrseward/vue-unit.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link