Skip to content

Mount method is impacted from previous test function #1050

Closed
@hoangnkvti

Description

@hoangnkvti

Version

1.0.0-beta.26

Steps to reproduce

I write some test for my child component. But below mount function can not render child component, if above function use shallowMount. But when I change first test function to mount, below function work properly.

What is expected?

Function mount work properly

What is actually happening?

Function mount doesn't work properly


Here is my code:

test('test UI with create User', () => {
    const wrapper = shallowMount(AddUser, {
      localVue,
      store,
      mocks: {
        $router,
      },
    });
    console.log(wrapper.html());
    expect(wrapper.find('alertpanel-stub').exists()).toBe(true);
    expect(wrapper.find('userform-stub').exists()).toBe(true);
    expect(wrapper.find('button[id="addBtn"]').exists()).toBe(true);
  });
  test('add user with invalid input', async () => {
    const wrapper = mount(AddUser, {
      localVue,
      store,
      mocks: {
        $router,
      },
    });
    console.log(wrapper.html());
    wrapper.find('#addBtn').trigger('click');
    await flushPromises();
    expect(wrapper.vm.errors.count()).toBeGreaterThan(0);
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions