vue-jest
vue-jest copied to clipboard
Cannot resolve custom tsconfig from Jest configuration
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:
- Get rid of
tsconfig
and just check iftsConfigPath
exists and is a file (because this is whattsconfig
does); - Split
tsConfigPath
and pass toresolveTsConfigSync
path and file separately;