运行单个Mocha测试不使用IntelliJ和Typescript

时间:2017-06-10 17:51:13

标签: intellij-idea mocha

我安装了IntelliJ的NodeJS插件并运行所有mocha测试工作。

当我尝试运行单个套件时,Mocha为我生成一个配置,如下所示:

/usr/local/bin/node /usr/local/lib/node_modules/mocha/bin/_mocha \
--timeout 15000 \
--compilers ts:ts-node/register \
--ui bdd \
--reporter "/Users/Bersling/Library/Application Support/IntelliJIdea2017.1/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js" \
/Users/Bersling/Desktop/IT-Projects/typescript-mongo-express-angular-node-seed/backend/src/router/endpoints/login-router.test.ts \
--grep "LoginRouter "

但是,这对我不起作用。我得到了应该正常工作的测试错误。这是日志的一部分。

error:  Error: Internal Server Error
    at Test.Request.callback (/Users/Bersling/Desktop/IT-Projects/typescript-mongo-express-angular-node-seed/backend/node_modules/superagent/lib/node/index.js:626:17)
    at IncomingMessage.<anonymous> (/Users/Bersling/Desktop/IT-Projects/typescript-mongo-express-angular-node-seed/backend/node_modules/superagent/lib/node/index.js:795:18)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
(node:90972) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AssertionError: false == true
Error: Unknown authentication strategy "local"
    at attempt (/Users/Bersling/Desktop/IT-Projects/typescript-mongo-express-angular-node-seed/backend/node_modules/passport/lib/middleware/authenticate.js:173:37)

以下内容将起作用:

/usr/local/bin/node /usr/local/lib/node_modules/mocha/bin/_mocha \
--timeout 15000 \
--compilers ts:ts-node/register \
--ui bdd \
--reporter "/Users/Bersling/Library/Application Support/IntelliJIdea2017.1/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js" \
**/*.test.ts \
--grep "LoginRouter "

像这样,测试运行良好。

有谁知道如何让它运行?

1 个答案:

答案 0 :(得分:0)

今天我遇到了同样的错误。 尝试将Mocha重新安装到另一个版本,然后返回以前的版本。 这对我有用。