Closed
Description
Version: 4.0.0-beta.2
Problem
Documentation says that I can provide typescript configuration options using
jest.globals['vue-jest'].tsConfig
The problem is that tsConfig
option doesn't work and application's root tsconfig.json
is always being picked up.
I found that the problem is this code:
const getTsJestConfig = function getTsJestConfig(config) {
const createTransformer = require('ts-jest').createTransformer
const tr = createTransformer()
const { typescript } = tr.configsFor(config)
return { compilerOptions: typescript.options }
}
The code above relies on ts-jest
package to get typescript configuration and passes a whole jest config to it.
ts-jest
knows nothing about vue-jest
, and thus our jest.globals['vue-jest'].tsConfig
is just being ignored.
Proposed solution
To fix the problem I suggest to put tsConfig
options under jest.globals['ts-jest']
:
const getTsJestConfig = function getTsJestConfig(jestConfig) {
const createTransformer = require('ts-jest').createTransformer
const tr = createTransformer()
const tsConfig = getVueJestConfig(jestConfig).tsConfig;
const config = Object.assign(
{},
jestConfig || {},
{ globals: {'ts-jest': { tsConfig }}}
);
const { typescript } = tr.configsFor(config)
return { compilerOptions: typescript.options }
}
I can prepare a PR if we agree on the solution