jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.24k stars 508 forks source link

How do I use Mocha with TSDX? #921

Closed dgreene1 closed 3 years ago

dgreene1 commented 3 years ago

I'm putting this information here in case anyone else is looking to do this:

Solution:

  1. modify your package.json to use the example provided here
  2. following the instructions here so you can ignore the Jest types
dgreene1 commented 3 years ago

Self-answered

agilgur5 commented 3 years ago

You can also use --require ts-node/register, though it is slower than just compiling then running tests.

dgreene1 commented 3 years ago

Thanks, yes. The main reason I made this post is to share that you have to resort to some unique hacks to get the Jest types out of the way. I describe that more in detail in the second link I placed above.

agilgur5 commented 3 years ago

Yea that's suboptimal experience. I've been looking to split up the commands for a while now (e.g. #407 is an initial step toward that) so that if you wanted to, instead of installing tsdx, you install @tsdx/rollup and @tsdx/eslint but not @tsdx/jest in this case. That would also open it up for a @tsdx/mocha for instance too.