Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tsConfig option doesn't work #171

Copy link
Copy link
Closed
@aantipov

Description

@aantipov
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.