Skip to content

Bug: regression on wrapper.vm type in 2.4.0-alpha.0 #2060

@cexbrayat

Description

@cexbrayat

Describe the bug

test('mount component', async () => {
  expect(Hello).toBeTruthy();

  const wrapper = mount(Hello, {
    props: {
      count: 4,
    },
  });

  // something does not exist on vm
  expect(wrapper.vm.something).toBe(undefined);
});

To Reproduce
https://stackblitz.com/edit/vitest-dev-vitest-se33u3?file=package.json

The type checking throws in v2.3.2 (as it should because wrapper.vm.something does not exist):

test/basic.test.ts:13:21 - error TS2339: Property 'something' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: { readonly count: number; key?: string | number | symbol; ref?: VNodeRef; ref_for?: boolean; ref_key?: string; ... 7 more ...; style?: unknown; }; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ...'.

13   expect(wrapper.vm.something).toBe(undefined);

Bump to v2.4.0-alpha.0, and run the command again: the error is now not caught.

npm install && npm run tsc

Expected behavior

The error should be caught in v2.4.0

Related information:

  System:
    OS: Linux 5.0 undefined
    CPU: (2) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  npmPackages:
    @vue/test-utils: 2.4.0-alpha.0 => 2.4.0-alpha.0 
    vitest: latest => 0.31.0 
    vue: latest => 3.3.2 

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions