Is it possible to use different tsconfig file for vitest
Asked Answered
G

2

9

Is there any way to use different tsconfig file for vitest?

I have a large project using vue-cli. Before converting it to vite based I first want to use vitest instead of jest. The problem is that the tsconfig.json file is using 'target: es2015' and for vitest it should be 'target: esnext'

Gam answered 17/7, 2022 at 6:53 Comment(2)
searching for the sameKassia
One of the good things about vitest is that you can reuse your rollup and ts config to avoid extra configurations. I'm not sure that there is easy way to override tsconfigAlmira
B
1

Yes, this is possible via the typecheck.tsconfig option in your vitest configuration. This is the relevant part of the documentation.

Busey answered 16/8, 2023 at 13:12 Comment(0)
C
0

Ideally, we could set a path to a different tsconfig in the vitest configuration. However, I couldn't find such an option.

A workaround that might work in some scenarios would be an inverted pattern:

  • Instead of having a main tsconfig.json to build the project and a tsconfig.test.json to run the tests
  • We could use tsconfig.json for editor support inside the whole project (including tests) and for defining the test tsconfig options (vitest will pick those up)
    • Then use a separate tsconfig.build.json to define only build relevant settings (tsc -p ./tsconfig.build.json)

This allows to limit emitted build output by rootDir, include, etc.

Card answered 22/4, 2023 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.