Я пытаюсь настроить ts-node с помощью мокко, однако тестовый сценарий всегда терпит неудачу.
Я пробовал
mocha --require ts-node/register --extensions ts,tsx --watch --watch-files src 'src/**/*.spec.{ts,tsx}'
и
mocha --require ts-node/register src/**/*.spec.ts
Также я пытался установить ts-node локально и глобально, но всегда это результат
> project@1.0.0 test /home/moamen/foo/baz
> mocha --require ts-node/register src/**/*.spec.ts
(node:48106) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Object.help (/home/moamen/foo/baz/node_modules/yargs/lib/usage.js:240:22)
at Object.self.showHelp (/home/moamen/foo/baz/node_modules/yargs/lib/usage.js:432:15)
at Array.<anonymous> (/home/moamen/foo/baz/node_modules/mocha/lib/cli/cli.js:53:13)
at Object.fail (/home/moamen/foo/baz/node_modules/yargs/lib/usage.js:41:17)
at /home/moamen/foo/baz/node_modules/yargs/lib/command.js:246:36
(Use `node --trace-warnings ...` to show where the warning was created)
(node:48106) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:48106) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
, а это мой tsconfig.json
{
"compilerOptions": {
"target": "es6" ,
"module": "commonjs",
"sourceMap": true ,
"outDir": "dist" ,
"strict": true ,
"moduleResolution": "node" ,
"esModuleInterop": true
},
"lib": ["es2015"]
}