K41*_*F4r 15 testing compilation path mocha.js typescript
在 TypeScript 中使用 paths + baseUrl 配置时,我在运行 mocha 时遇到问题
我的 tsconfig.js 设置如下:
"baseUrl": "./src/", /* Base directory to resolve non-absolute module names. */
"paths": {
"interfaces/*": [
"interfaces/*"
],
"models/*": [
"models/*"
],
"schemas/*": [
"schemas/*"
],
"classes/*": [
"classes/*"
],
"libs/*": [
"libs/*"
],
"config/*": [
"config/*"
]
Run Code Online (Sandbox Code Playgroud)
我将 mocha 运行为“mocha build/test”
编译后的 TS 代码无法找到我的引用,因为它编译为
var user_1 = require("interfaces/user");
Run Code Online (Sandbox Code Playgroud)
如果我事先添加“../”,它将毫无问题地编译
你知道我在这里做错了什么吗?
小智 22
您可以使用,按照tsconfig-pathstsconfig-paths上的说明进行操作:
mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7928 次 |
| 最近记录: |