I'm having an issue with running mocha when using the paths + baseUrl configuration in TypeScript
My tsconfig.js is set like so:
"baseUrl": "./src/", /* Base directory to resolve non-absolute module names. */
"paths": {
"interfaces/*": [
"interfaces/*"
],
"models/*": [
"models/*"
],
"schemas/*": [
"schemas/*"
],
"classes/*": [
"classes/*"
],
"libs/*": [
"libs/*"
],
"config/*": [
"config/*"
]
and I'm runnings mocha as "mocha build/test"
The compiled TS code fails to find my references since it compiles to
var user_1 = require("interfaces/user");
and if I add "../" beforehand it will compile without problems
Any ideas what I'm doing wrong here?
You can use tsconfig-paths
, follow the instructions on tsconfig-paths:
mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"
You should use a mocha-TypeScript integration package, such as ts-mocha
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With