You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import'../src/declarations';importAppfrom'../src/App.vue';describe('Hello.vue',()=>{
let vm: App;it('should render correct contents',()=>{vm=(newApp).$mount();expect(vm.msg).toBe('Welcome to Your Vue.js App');})});
I don't think declarations.ts matters, but just in case:
Everything works great, my tests pass/fail as expected, I get autocomplete in WebStorm as I'm writing my tests. Except...the TypeScript language service gives me:
Error:(6, 13) TS2304:Cannot find name 'App'.
...for the line with:
let vm: App;
If I omit the type declaration the error goes away. But then it complains for everything on vm, as it thinks is is a Vue instance, not my TypeScript class.
I can, of course, do testing the way you do, with no $mount. Or I can do as you suggest in the ticket about component instances, and don't think in terms of typing in tests, and work down at the generated ES6 layer. But it would sure feel nice to get some typing.
The text was updated successfully, but these errors were encountered:
Your problem is, probably, not fixable in the library.
Single File Component is not compiled by TypeScript compiler. You can use SFC because you have used ts-loader to extract script from SFC. However, TypeScript language service does not have such functionality, so came the error.
I'm afraid this is out of av-ts' scope. But I appreciate your clear issue reporting.
My suggestion is
just ignore language service. Actually I wonder where you use LS.
writing test in JavaScript. Not ideal, but makes compile error / type assertion walk away.
Thanks for the fast response, and I understand what you're saying. I had a feeling it was a fundamental issue with the .vue SFC approach. To answer the question about LS, I'm using it in WebStorm (I'm the WebStorm Developer Advocate) which just shipped support for Vue.
This one is kind of weird. I have a Jasmine test:
I don't think
declarations.ts
matters, but just in case:My
App.vue
file has a<script>
block with:Everything works great, my tests pass/fail as expected, I get autocomplete in WebStorm as I'm writing my tests. Except...the TypeScript language service gives me:
...for the line with:
If I omit the type declaration the error goes away. But then it complains for everything on vm, as it thinks is is a Vue instance, not my TypeScript class.
I can, of course, do testing the way you do, with no
$mount
. Or I can do as you suggest in the ticket about component instances, and don't think in terms of typing in tests, and work down at the generated ES6 layer. But it would sure feel nice to get some typing.The text was updated successfully, but these errors were encountered: