Vue-jest: V4.0.0-beta.0: extends in tsconfig.json does not work as expected.

Created on 9 Jan 2019  路  4Comments  路  Source: vuejs/vue-jest

tsConfig.json

{
  "extends": "./.temp/tsconfig-base.json"
}

tsconfig-base.json


{
  "include": ["../src/**/*", "../types/**/*.d.ts", "./loader-types.d.ts", "./client-types.d.ts"],
  "exclude": ["../src/**/*.spec.ts", "../src/**/*.spec.js"],
  "compilerOptions": {
    "strict": true,
    "skipLibCheck": true,
    "module": "esnext",
    "target": "es6",
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "lib": ["dom", "es6", "dom.iterable", "scripthost"],
    "noEmitHelpers": true,
    "importHelpers": true,
    "inlineSources": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "baseUrl": ".",
    "paths": {
      "~ngAppModule": ["./ng-app-module"]
    },
    "outDir": "../dist/",
    "rootDir": "../src"
  }
}

When I tried debugging this issue, it logs
{"extends":"./.temp/tsconfig-base.json","compilerOptions":{}} at https://github.com/vuejs/vue-jest/blob/master/lib/compilers/typescript-compiler.js#L11

related to #118

bug

Most helpful comment

From what I read, vue-jest v3 uses a very old package to resolve tsconfig.json, needed before TypeScript exposed config resolution features.
This package doesn't support configuration inheritance. A PR has been started, but never finished and merged.

I found this bug while making Quasar framework work nicely with TS and Jest, in which a esModuleInterop property from a preset configuration wasn't being picked up in the extending configuration, while everything worked fine when adding the property directly on the former.

Anyway, seems like the new V4 will support ts-jest which should manage inheritance correctly (it used native TS configuration management), so I guess the problem will be solved in some time.

Cya!

All 4 comments

I can confirm this issue as well. I have been attempting to implement testing in Nuxt leveraging Jest. The default recommended config for nuxt-ts is:

{
  "extends": "./node_modules/nuxt-ts/tsconfig.nuxt-ts.json"
}

Eventually I chased it down to a failure to load the extended attributes into the referenced object as previously mentioned by @yohodopo

can confirm this is happening aswell :(

i was trying to debug why my typescript decorator is having it's 3rd argument as undefined in the test but has value in app code.

NOTE The Property Descriptor will be undefined if your script target is less than ES5.

I assumed it was in vue-jest because it was trying to test a .vue file with lang="ts"

I tried tweaking the tsConfig option for vue-jest and finally managed to reproduce it if i didn't extend my config.. which is where my target option lies

From what I read, vue-jest v3 uses a very old package to resolve tsconfig.json, needed before TypeScript exposed config resolution features.
This package doesn't support configuration inheritance. A PR has been started, but never finished and merged.

I found this bug while making Quasar framework work nicely with TS and Jest, in which a esModuleInterop property from a preset configuration wasn't being picked up in the extending configuration, while everything worked fine when adding the property directly on the former.

Anyway, seems like the new V4 will support ts-jest which should manage inheritance correctly (it used native TS configuration management), so I guess the problem will be solved in some time.

Cya!

I am using "@vue/cli-service": "4.5.8", and still experience this issue.

To test I:

  1. Made a valid tsconfig.json (without extends), ran my test suite, and they passed
  2. moved tsconfig.json to tsconfig.base.json and created tsconfig.json with contents:
{
  "extends": "./tsconfig.base.json"
}
  1. Ran tests again, and they fail
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rmartins90 picture rmartins90  路  6Comments

mazipan picture mazipan  路  10Comments

nothingismagick picture nothingismagick  路  4Comments

lmiller1990 picture lmiller1990  路  9Comments

Loremaster picture Loremaster  路  7Comments