0

I have the following setup:

  1. Build process with webpack and ts-loader
  2. Wanting to use test runner such as Karma to unit test the TS files

How do I best unit test TypeScript files with test runner in this webpack project? Its obvious to me how to do this with js projects, but need a proven workflow for this situation.

Nikos
  • 7,295
  • 7
  • 52
  • 88

1 Answers1

2

You can create a separate entry point for your test files in webpack, or you can compile ts before running webpack. I'd typically go for the latter

You can compile ts projects with the command tsc -p . and it will convert all .ts files to .js ones. Then you can get rid of the ts-loader and just treat everything as a js file.

Louay Alakkad
  • 7,132
  • 2
  • 22
  • 45