Open
Description
Observed:
While editing the following test file,
// App.spec.ts
import { mount } from "@vue/test-utils"
import { describe, it, expect } from "vitest"
import App from "../src/App.vue"
describe("App", () => {
it("toggles", () => {
const wrapper = mount<typeof App>(App)
expect(wrapper.element.tagName).toBe("DIV")
expect(wrapper.vm.editButton).toBeFalsy()
});
});
for this .vue file:
// App.vue
<template>
<div> <input type="button" :value="String(editButton)" @click="editButton = !editButton" /> </div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const editButton = ref<boolean>(false)
</script>
the type of wrapper.vm
is ComponentPublicInstance
instead of the specific type of the component. This causes the following to be displayed:
However, the test runs without a problem.
Expected behavior: Volar will reference the component type when validating code, and not report a problem if there isn't one.
Example project to reproduce problem: https://github.com/stevemandl/vitest_sample