1

New to the typescript. I'm trying to use mocha framework to add unit tests to one our nodeJS/typescript projects.

Our typescript application uses tsc compiler with esnext module.

I couldn't able to make Mocha to use esnext module to run the tests (it works fine with commonjs module). Seems like ts-node doesn't detect the imports with esnext module, but it has no issues when used with commonjs module.

  • So, I'm wondering is it a good practice to use different compiler and module combination between project build process and unit tests? i.e. tsc and esnext for build process and ts-node and commonjs for unit test.
  • Are there any potential issues/risks we might face in future if we proceed with this approach?
  • Is there any way to make Mocha to use tsc with esnext or ts-node with commonjs or ts-node with esnext?
  • Or Am I missing something conceptually with the way typescript or Mocha work?
4

0 回答 0