Comments (23)
@mikemenaker @chlab I confirm that SFC with no script section do work with version 1.0.0 vue-jest
But you need to define the template as <template functional>
from vue-jest.
@icaioincau Try again changing your template to <template functional>...</template>
from vue-jest.
It worked :D
from vue-jest.
Hi! I've still got error with 'lang' in 1.0.2 version. Any way to fix it without adding functional to template?
from vue-jest.
Thanks for posting the component @Ca4tkin 😀
I've pushed a fix in 1.0.3
from vue-jest.
Hi, thanks for the bug report
I downloaded the webpack repo and failed to reproduce the issue. Would you be able to post the test file and component where you're getting this error, or even better post a reproduction repo?
from vue-jest.
I ran into this issue as well.
I resolved it by changing the function process.js to:
function processScript (scriptPart) {
if(scriptPart != null && scriptPart.hasOwnProperty("lang")) {
if (scriptPart.lang === 'typescript' || scriptPart.lang === 'ts') {
return compileTypescript(scriptPart.content)
}
if (scriptPart.lang === 'coffee' || scriptPart.lang === 'coffeescript') {
return compileCoffeeScript(scriptPart.content)
}
return compileBabel(scriptPart.content)
}
return compileBabel(null)
}
I can make a pull request with this change or you might want to handle it a different way.
from vue-jest.
I would appreciate a PR, and ideally a unit test with a case that fails. Thanks 🙂
from vue-jest.
Cool, should have something today or tomorrow.
I think this issue popped up because I was using functional SFC with no script section (just a template).
from vue-jest.
Looks like this will handle the issue I ran into:
#17
Any idea when a new release will go out?
Thanks!
from vue-jest.
I've just released in 1.0.0 vue-jest.
Note I've changed the package name to vue-jest. You can still download jest-vue, but it won't be receiving further updates.
To install the new version:
npm install --save-dev vue-jest
I made a request to the original owner of vue-jest to transfer ownership to this repository so that the package name could be more idiomatic to other preprocessors like babel-vue and ts-vue.
from vue-jest.
There was another problem when testing nested functional components with mount. This pull request solves the issue:
#22
from vue-jest.
@eddyerburgh sorry for the late reply.
This is the repo that I'm encountering these problems. It has one unit test. I'm no longer seeing the lang
error, but I'm still seeing the problems described in the PR.
Do you mind having a quick look? Can you run npm run unit
without any problems?
Thanks!
from vue-jest.
I am having the same problem here :(, the lang one.
from vue-jest.
@icaioincau is this fixed for you in 1.0.1? If not, can you post the error?
from vue-jest.
Oh! I had oversimplified the parsing of the funcional templates and had forgotten some cases like passing a function or an array as props.
I just updated the pull request and I hope that this solves most of the common issues but more edge cases should arise so I'll keep an eye on this.
@eddyerburgh Sorry for the inconvenience, could you run a new release and test it with some complex functional templates please?
from vue-jest.
I've released the changes in 1.0.2
from vue-jest.
Cool! I have a project with different funcional components and it works. Let's see if we find new edge cases. Thanks for the release!
from vue-jest.
Hi @eddyerburgh my components is this:
<template>
<section class="error-page__partial">
<h1 class="error-page__main-title"> {{ $t('i18n.private') }} </h1>
<h3>Lorem Ipsum at dolor sit amen</h3>
</section>
</template>
He is on a main component that has a script.
<template>
<section class="error-page" :class="modifiers">
<div>
<h1 class="error-page__main-title"> {{ $t('i18n.private') }} </h1>
<h3 v-html="$t('i18n.private')"></h3>
</div>
<partial></partial> <!-- Here -->
</section>
</template>
The error:
TypeError: Cannot read property 'lang' of null
at processScript (node_modules/jest-vue/lib/process.js:13:17)
at Object.module.exports [as process] (node_modules/jest-vue/lib/process.js:27:18)
at src/views/ErrorPage/ErrorPage.vue:8:14
at Object.<anonymous> (src/views/ErrorPage/ErrorPage.vue:106:3)
Version used: 1.0.2
from vue-jest.
@Ca4tkin can you post the SFC that you're getting the error with?
from vue-jest.
@eddyerburgh, here it is:
<template>
<footer class="footer">I'm footer!</footer>
</template>
<style>
.footer {
padding: 15px;
border: 1px dashed red;
text-align: center;
margin-top: 30px;
}
</style>
from vue-jest.
Thanks @eddyerburgh 1.0.3 fixed the issue in my projects.
from vue-jest.
@eddyerburgh thanks! It's fixed
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的?
- Bug: Props detection broken with jest since 2.4.2 (works in 2.4.1) HOT 7
- 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.