Git Product home page Git Product logo

Comments (5)

dobromir-hristov avatar dobromir-hristov commented on May 14, 2024 1

My two cents here. You should probably just create a simple mock of the library and pass it to the mocks property of vue-test-utils.
A simple rule to follow is, what is not yours, dont test/mock it. This would mean we have to create a wrapper around the lib but lets be real here... we just assume it all works (as it should) and we create a simple mock. Otherwise you will have to install the plugin for the test too.

from vue-wait.

gabrielrobert avatar gabrielrobert commented on May 14, 2024 1

In some cases, we cannot mock v-wait. This library is widely used in our project and stubs/mocks prevent proper testability. For instance:

Component:

<v-wait for="loading">
   <Spinner slot="waiting" />
   <ul class="suggestions" v-if="suggestions">
      <li v-for="...">Bleh</li>
   </ul>
</v-wait>

Test:

it('shows suggestions', async () => {
    const wrapper = shallowMount(SuggestionsComponent, { localVue });
    expect(wrapper.find('.suggestions').exists()).toBe(true);
});

It is not possible to test proper ul rendering without v-wait component. You should:

const localVue = createLocalVue();
localVue.use(Vuex);
localVue.use(VueWait);

it('shows suggestions', async () => {
    const wrapper = shallowMount(SuggestedAddresses, {
      localVue,
      wait: new VueWait()
    });
    expect(wrapper.find('.suggestions').exists()).toBe(true);
});

from vue-wait.

f avatar f commented on May 14, 2024 1

Hi @gabrielrobert, would you help to add a "testing" part into README.md file according to your testing experiences and problems? I need to improve vue-wait to make it more testable. It would be awesome for the people asking for tests (including me) :)

from vue-wait.

giubatt avatar giubatt commented on May 14, 2024

I think you didn't paste all the code, I don't see 'isLoading' anywhere.

In another note, you shouldn't be importing Vue in your tests, that's what createLocalVue is for

from vue-wait.

f avatar f commented on May 14, 2024

I think @dobromir-hristov's answer is the answer. Closing this issue.

from vue-wait.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.