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
{{ message }}
Repository navigation
Vite Build fails because of test TypeScript error #1191
~/public_html/spec-rep main npm run test ✔
> laksmi@3.0.0 test
> jest src
PASS src/components/SearchDetailed.spec.ts
SearchDetailed inAccountNumberRange
✓ returns true as no accountStart (12 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.987 s, estimated 1 s
Ran all test suites matching /src/i.
Build
~/public_html/spec-rep main npm run build ✔
> laksmi@3.0.0 build
> vue-tsc --noEmit && vite build
src/components/SearchDetailed.spec.ts:9:23 - error TS2339: Property 'inAccountNumberRange' does not exist on type '{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<{ results?: unknown; accountStart?: unknown; } & { results: unknown[]; } & { accountStart?: string | undefined; }> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch(source: string | Function, cb:...'.
9 expect(wrapper.vm.inAccountNumberRange('452')).toBe(true)
~~~~~~~~~~~~~~~~~~~~
Found 1 error.
Thanks, that's what I was suspecting: your component is using script setup so this TS error is sadly expected. See #972
We are doing some magic in VTU to make this test possible, but we are waiting for a fix in Vue itself to make this type-checking possible. In the meantime, you have to explicitly add a cast like (wrapper.vm) as unknown as { inAccountNumberRange: (n: string) => boolean }).
Activity
cexbrayat commentedon Dec 28, 2021
Hi @rrd108
It's hard to say what's going on without at least the component code and which versions are you using.
Would you mind sharing a minimal reproduction with us? Ideally a GitHub repository with just the minimum required to reproduce your issue.
rrd108 commentedon Dec 29, 2021
@cexbrayat
Here is the repo: https://github.com/rrd108/vue-test-utils-1191
Outputs in my system.
Tests
Build
cexbrayat commentedon Dec 29, 2021
Thanks, that's what I was suspecting: your component is using
script setupso this TS error is sadly expected. See #972We are doing some magic in VTU to make this test possible, but we are waiting for a fix in Vue itself to make this type-checking possible. In the meantime, you have to explicitly add a cast like
(wrapper.vm) as unknown as { inAccountNumberRange: (n: string) => boolean }).You can track #972 and vuejs/core#4465
Closing this one as duplicates.