Comments (7)
You are right of course :) I'll update the issue.
from vue-jest.
Hi @sawmurai
Thanks for the repro.
I think the regression occurred between v2.4.1 and v2.4.2 no? Because v2.4.2 was the release with vuejs/test-utils@1db42c8 which changed the props()
type.
from vue-jest.
@johnsoncodehk would you mind taking a look at why vuejs/test-utils@1db42c8 introduced this regression? How should we type props()
to avoid that?
cc @alecgibson as well, as the original author of this change
from vue-jest.
Weirdly if I download this repro and run locally in VS Code, it seems fine:
![Screenshot 2024-03-20 at 14 33 53](https://private-user-images.githubusercontent.com/12036746/314540689-d2475658-57ed-42a7-8805-9c7ecae7fc99.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MDk2OTYsIm5iZiI6MTcyMzgwOTM5NiwicGF0aCI6Ii8xMjAzNjc0Ni8zMTQ1NDA2ODktZDI0NzU2NTgtNTdlZC00MmE3LTg4MDUtOWM3ZWNhZTdmYzk5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDExNTYzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI1MzAyYjkyZjEyY2E1YjdkNDA0ZjJhZmEzZTI4YzZkNGFjMzI5NGQwODQ4ODYyODA0YjQ0MTJiZWFmMTViMzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.KLzcrZsa1Zb2ajf-OtnQAvsahlFq_-AuSE3wu0LQICg)
npm run build
also works fine
from vue-jest.
It even correctly flags bad props:
![Screenshot 2024-03-20 at 14 35 50](https://private-user-images.githubusercontent.com/12036746/314541851-3ee4d2ad-ec32-40d0-901a-844f0879fb0d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4MDk2OTYsIm5iZiI6MTcyMzgwOTM5NiwicGF0aCI6Ii8xMjAzNjc0Ni8zMTQ1NDE4NTEtM2VlNGQyYWQtZWMzMi00MGQwLTkwMWEtODQ0ZjA4NzlmYjBkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE2VDExNTYzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZhN2NjMmI5MDYxNTk1N2MwYTY2ZjI1ZjY3YmQ2MzdjNTBhYmQ5YjVhN2E3YzMwMjQ1MDUwYTQyMzRjZDA1NGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.u5QhrHy7VNaFGOsnQel1Uc65pnIP0KbBA0ZIvTw_Uoo)
and fails npm run build
:
❯ npm run build
> [email protected] build
> vue-tsc && vite build
src/components/HelloWorld.spec.ts:14:26 - error TS2339: Property 'foo' does not exist on type '{ readonly msg: string; key?: string | number | symbol | undefined; ref?: VNodeRef | undefined; ref_for?: boolean | undefined; ref_key?: string | undefined; onVnodeBeforeMount?: VNodeMountHook | ... 1 more ... | undefined; ... 6 more ...; style?: unknown; } & Partial<...> & Omit<...>'.
14 expect(wrapper.props().foo).toBe('Hello world');
~~~
Found 1 error in src/components/HelloWorld.spec.ts:14
from vue-jest.
Oh I see, npm run build
passes, but running jest
fails. This feels like a jest
misconfiguration, or an issue with the @vue/vue3-jest
transformer or its configuration
Edit: or the ts-jest
transformer could also be the issue
from vue-jest.
Thanks for looking into it @alecgibson !
I'll transfer to the vue-jest repo then, as it does feel like a Jest specific issue 👍
from vue-jest.
Related Issues (20)
- install errors
- Unable to mock $style object on a Vue 3 Options API based component using CSS Modules
- Issue with script and script setup in the same vue file HOT 5
- Upgrade TS target to ES6 HOT 3
- `compilerOptions` in `jest.globals` not taking effect? HOT 7
- Instructions for setting up `vue-test` when migrating from Vue 2 to Vue 3? HOT 1
- New test fail with mistake ENOENT: no such file or directory, open HOT 1
- Using v8 as the coverageProvider, used files without tests are being reported with 100% coverage HOT 2
- Test fails to run when using CSS v-bind and parent directory starts with "x"
- DOCS: vue-jest 4.x doesn't support jest 25.x
- Cannot find module '@babel/preset-env'
- v-bind(css) + number prefix folder path + windows : make a syntax error HOT 1
- Incompatibility with Prettier v3 HOT 4
- Injecting SFC styles into the DOM using JSDom test environment HOT 1
- @use rules must be written before any other rules.
- Newest version on npmjs.com is 5.x alphs, but on GitHub it's up to 29.x
- Single uncovered line flagged by Vue `template` HOT 2
- 组件测试的时候,vuewrapper里面拿到的vm是空,使用的script setup写法,optionsApi写法是ok的?
- Tests fail due to "Cannot destructure property 'config' of 'undefined' as it is undefined."
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-jest.