Skip to content

Is the example really showcasing the type of the HelloWorld Vue? #1

@chenxeed

Description

@chenxeed

Hi @eddyerburgh , appreciate for the example you've made.

I want to make sure if the example I was looking for, match with the example here.

Basically, I need to write a test that has integration with my component's interface.

So I modify your test file a bit, to be like this:

describe('HelloWorld.vue', () => {
  test('renders props.msg when passed', () => {
    const msg = 'new message';
    const wrapper = shallowMount<HelloWorld>(HelloWorld, {
      propsData: { msg },
    });
    expect(wrapper.text()).toMatch(msg);
    expect(wrapper.vm.msg).toMatch(msg); // add this new expectation
  });
});

And I got typescript error on the new expectation, saying:

screen shot 2018-09-22 at 7 11 17 pm

I saw that we can register the Vue instance on the mount<T>/shallowMount<T>, so I modified the wrapper to this:

    const wrapper = shallowMount<HelloWorld>(HelloWorld, {
      propsData: { msg },
    });

And then I got different error, which is the error that always troubling me because it can't get the HelloWorld instance:

screen shot 2018-09-22 at 7 10 51 pm

In the end, I still couldn't find a way to solve this problem, perhaps do you think this is a bug or not supported yet?

If so, I also wonder on where should I report this, and if there's a recommended way for me to help, I would like to. Thank you @eddyerburgh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions