GithubHelp home page GithubHelp logo

Comments (23)

agualis avatar agualis commented on August 22, 2024 2

@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.

agualis avatar agualis commented on August 22, 2024 2

@icaioincau Try again changing your template to <template functional>...</template>

from vue-jest.

caioincau avatar caioincau commented on August 22, 2024 2

It worked :D

from vue-jest.

wienska avatar wienska commented on August 22, 2024 1

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.

eddyerburgh avatar eddyerburgh commented on August 22, 2024 1

Thanks for posting the component @Ca4tkin 😀

I've pushed a fix in 1.0.3

from vue-jest.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

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.

mikemenaker avatar mikemenaker commented on August 22, 2024

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.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

I would appreciate a PR, and ideally a unit test with a case that fails. Thanks 🙂

from vue-jest.

mikemenaker avatar mikemenaker commented on August 22, 2024

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.

mikemenaker avatar mikemenaker commented on August 22, 2024

Looks like this will handle the issue I ran into:
#17

Any idea when a new release will go out?

Thanks!

from vue-jest.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

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.

agualis avatar agualis commented on August 22, 2024

There was another problem when testing nested functional components with mount. This pull request solves the issue:
#22

from vue-jest.

chlab avatar chlab commented on August 22, 2024

@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.

caioincau avatar caioincau commented on August 22, 2024

I am having the same problem here :(, the lang one.

from vue-jest.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

@icaioincau is this fixed for you in 1.0.1? If not, can you post the error?

from vue-jest.

agualis avatar agualis commented on August 22, 2024

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.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

I've released the changes in 1.0.2

from vue-jest.

agualis avatar agualis commented on August 22, 2024

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.

caioincau avatar caioincau commented on August 22, 2024

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.

eddyerburgh avatar eddyerburgh commented on August 22, 2024

@Ca4tkin can you post the SFC that you're getting the error with?

from vue-jest.

wienska avatar wienska commented on August 22, 2024

@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.

maxmilton avatar maxmilton commented on August 22, 2024

Thanks @eddyerburgh 1.0.3 fixed the issue in my projects.

from vue-jest.

wienska avatar wienska commented on August 22, 2024

@eddyerburgh thanks! It's fixed

from vue-jest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.