Code Monkey home page Code Monkey logo

Comments (5)

404157386 avatar 404157386 commented on May 18, 2024

if the shallow render doesn't load child component Message.vue?
i try to use mount, but also hint error -- wrapper.hasProp() must be called on a Vue instance.
bcoz Message.vue is a functional component?

from vue-test-utils-mocha-webpack-example.

eddyerburgh avatar eddyerburgh commented on May 18, 2024

This package is using an old version of vue-test-utils. I'll look into it later today

from vue-test-utils-mocha-webpack-example.

404157386 avatar 404157386 commented on May 18, 2024

Hello, I hvae a question:
At MessageToggle.vue, Message is a child component ,

I want to get its props by wrap.find , but it's not a Vue instance, can't use wrapper.props() with latest version vue-test-utils...
How can I do this?

    const wrapper = shallow(MessageToggle)
    const button = wrapper.find('#toggle-message')
    
    const MessageComponent = wrapper.find(Message)
    expect(MessageComponent.hasProp('msg', 'message')).toBe(true) _//can't get props for it's not vue instance_

If a component import any child component, should i test child?
It's still unit test?

from vue-test-utils-mocha-webpack-example.

eddyerburgh avatar eddyerburgh commented on May 18, 2024

This is only an issue for functional components. We changed how we treat functional components under the hood in the latest version, so it's not possible to check the props on a functional component. This is a bug that will be fixed in the next version 👍

You can still check child components in the way demonstrated in this repo for all other types of components

from vue-test-utils-mocha-webpack-example.

eddyerburgh avatar eddyerburgh commented on May 18, 2024

I've updated the code to use a non-functional component

from vue-test-utils-mocha-webpack-example.

Related Issues (11)

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.