Will this play nicely with jest?
See original GitHub issueFirst of all–thank you SO much. I’ve been hoping one of the core Vue members would backport script setup to Vue 2.
The only adoption concern I have left after reading the readme is whether this will break my jest tests. I guess it wouldn’t be too hard for me to write a basic jest transform using the JavaScript API. But I wasn’t sure whether that would play nicely with vue-jest
. Any thoughts on this.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:18 (7 by maintainers)
Top Results From Across the Web
How to Make SonarCloud Play-Along Nicely with Jest
It's a pretty simple setup. I'm using Jest (version 25.1.0) installed globally with npm install jest -g (cos why not) with tests located...
Read more >Getting jest to play nicely with webpack static assets imports ...
Turns out it was fine before, but now since the css is imported in the component file, jest does not know what to...
Read more >Getting Started - Jest
You just successfully wrote your first test using Jest! This test used expect and toBe to test that two values were exactly identical....
Read more >How to Make SonarCloud Play-Along Nicely with Jest - Morioh
You cannot pass Jest coverage data directly into SonarCloud, so you need to use an intermediary to convert it into a format SonarCloud...
Read more >Testing your Solid.js code with jest - DEV Community
Jest is currently one of the best options for front end testing, but it requires some setup to play nicely with Solid.js.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok so for those running into this issue here’s the solution:
create a file
vue-setup-transformer.js
:and then in your
jest.config.js
replacevue-jest
with this custom transformer:I don’t know where i could submit this PR or how to do it, but if you let me know i could most likely do a pr here or for vue-jest?
Edit: This still seems to have trouble when transforming with external dependencies. it fails at the
const transformed = transform(source, filename);
and never goes into thevue-jest.process
Trying to figure out why
First off, I am amazed this has been ported to Vue 2. Well done! I haven’t looked at how it’s implemented exactly, but assuming there is no technical blocker, we could support this in
vue-jest
.Considering Vue 2 will not have many more big updates, maintenance should not be too difficult. I am not sure I have time to work on this right now, but since most of the work is done in this code base, I’m guess we just:
vue-jest
vue-jest
transform, we pass the input to this module, changing the code into a regular SFCvue-jest
do the rest of the transform