【问题标题】:Running a single Mocha test not working with IntelliJ and Typescript运行单个 Mocha 测试不适用于 IntelliJ 和 Typescript
【发布时间】:2017-06-10 17:51:13
【问题描述】:

我为 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 "

这样测试运行良好。

有谁知道我怎样才能让它运行?

【问题讨论】:

    标签: intellij-idea mocha.js


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-02
      • 2020-06-26
      • 2018-07-24
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      • 2023-03-31
      • 1970-01-01
      相关资源
      最近更新 更多