vue-jest icon indicating copy to clipboard operation
vue-jest copied to clipboard

Cannot resolve custom tsconfig from Jest configuration

Open kwiniarski opened this issue 3 years ago • 0 comments

I wanted to avoid tsconfig.json in root directory of my project. For unit tests I wanted to use tsconfig.spec.json. However when I provide this option in jest.config.js as

globals: {
  'vue-jest': {
    tsConfig: 'tsconfig.spec.json',
  },
},

it is properly resolved but fails on:

https://github.com/vuejs/vue-jest/blob/7ee1af9e61a843c2eec2dc6c88c669c3cd595507/packages/vue3-jest/lib/utils.js#L76-L79

const isUsingTs = resolveTsConfigSync(tsConfigPath) receives valid path to existing file, but returns undefined. In tsconfig package we can see, that if we call this function with only one parameter it will jump to find path, where filename always defaults to tsconfig.json:

https://github.com/TypeStrong/tsconfig/blob/3d0586d30a85e1098d4a966e6b563d58abc42620/src/tsconfig.ts#L49-L59

From my perspective it could be solved in two ways:

  1. Get rid of tsconfig and just check if tsConfigPath exists and is a file (because this is what tsconfig does);
  2. Split tsConfigPath and pass to resolveTsConfigSync path and file separately;

kwiniarski avatar Nov 27 '21 16:11 kwiniarski