vuejs / vue-jest

Jest Vue transformer
MIT License
742 stars 159 forks source link

🐛 BUG: Import of vue file results in error #531

Open sschneider-ihre-pvs opened 1 year ago

sschneider-ihre-pvs commented 1 year ago

When I try to run tests that include imports of vue files I get this weird error message. btw there is no actual file file.js @IlCallo just in case you also have an idea also, this looks a bit like babel expected a js file while given ts?!

  transform: {
    '^.+\\.js$': 'babel-jest',
    '^.+\\.ts$': 'ts-jest',
    '^.+\\.vue$': '@vue/vue3-jest',

    '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$':
      'jest-transform-stub',
  },

also doesn't matter if I use babel-jest or ts-jest for ts files.

file.js: Unexpected token, expected "," (3:27)

      1 | import { resolveComponent as _resolveComponent, mergeProps as _mergeProps, openBlock as _openBlock, createBlock as _createBlock } from "vue"
      2 |
    > 3 | export function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {
        |                            ^
      4 |   const _component_q_input = _resolveComponent("q-input")!
      5 |
      6 |   return (_openBlock(), _createBlock(_component_q_input, _mergeProps(_ctx.$attrs, {

@babel+parser@7.20.15 @babel+core@7.20.12 @jest+transform@29.4.2 @vue+vue3-jest@29.2.2

sschneider-ihre-pvs commented 1 year ago

Guess around there has to be the problem https://github.com/vuejs/vue-jest/blob/4855375fb32d929df29ef1ce3ba3c5518a1ef058/packages/vue3-jest/lib/process.js#L138

sschneider-ihre-pvs commented 1 year ago

could it be that vue-jest by default looks in the cwd for a tsconfig.json instead of ?