简体   繁体   English

在节点检查器中运行超级测试时,无法读取null的属性“ _host”

[英]Cannot read property '_host' of null when running supertest in node-inspector

I'm fairly new to the Angular world and have been using the angular-fullstack generator + Yeoman to build out a project. 我对Angular世界还很陌生,并且一直在使用angular-fullstack生成器+ Yeoman构建项目。 I'm using Sublime (not Webstorm) and have been trying to figure out how to set up the project so that I can debug the mocha tests from the terminal, but am hitting a wall. 我正在使用Sublime(不是Webstorm),并且一直在试图弄清楚如何设置项目,以便可以从终端调试mocha测试,但遇到了麻烦。

Here's the default things.spec.js that's generated with 'yo angular-fullstack' with a debugger statement added in. 这是使用添加了调试器语句的'yo angular-fullstack'生成的默认Things.spec.js。

var should = require('should');
var app = require('../../app');
var request = require('supertest');

describe('GET /api/things', function() {
   it('should respond with JSON array', function(done) {
       request(app)
          .get('/api/things')
          .expect(200)
          .expect('Content-Type', /json/)
          .end(function(err, res) {
              debugger;
              if (err) return done(err);
              res.body.should.be.instanceof(Array);
              done();
          });
   });
});

By combining advice from the grunt-mocha-test documentation and this SO answer , I've updated the test script in package.json as follows: 通过结合来自grunt-mocha-test文档的建议和该SO答案 ,我更新了package.json中的测试脚本,如下所示:

"scripts": {
    "test": "node-debug <PATH TO GRUNT-CLI>\\grunt test"
}

When I run 'npm test', node-inspector successfully boots up a browser instance and attaches the debug session to my test process. 当我运行“ npm test”时,node-inspector成功启动了浏览器实例,并将调试会话附加到我的测试过程中。 However, when I press "continue", the debugger breakpoint is NOT hit and the test fails with the following stack. 但是,当我按“继续”时,调试器断点未命中,并且测试失败并显示以下堆栈。 Anyone have any clues as to what's causing this? 任何人都知道这是什么原因的任何线索?

TypeError: Cannot read property '_host' of null
  at ClientRequest.http.ClientRequest.onSocket (eval at WRAPPED_BY_NODE_INSPECTOR (\node_modules\node-inspector\node_modules\v8-debug\v8-debug.js:95:15), <anonymous>:381:28)
  at new ClientRequest (http.js:1432:10)
  at Object.exports.request (http.js:1843:10)
  at Test.Request.request (\node_modules\supertest\node_modules\superagent\lib\node\index.js:615:28)
  at Test.Request.end (\node_modules\supertest\node_modules\superagent\lib\node\index.js:677:18)
  at Test.end (\node_modules\supertest\lib\test.js:123:7)
  at Context.<anonymous> (\server\api\thing\thing.spec.js:14:8)
  at Test.Runnable.run (\node_modules\grunt-mocha-test\node_modules\mocha\lib\runnable.js:196:15)
  at Runner.runTest (\node_modules\grunt-mocha-test\node_modules\mocha\lib\runner.js:374:10)
  at Runner.runTests.next (\node_modules\grunt-mocha-test\node_modules\mocha\lib\runner.js:452:12)

This looks like a bug in Node Inspector. 这看起来像Node Inspector中的错误。 https://github.com/node-inspector/node-inspector/issues/698 https://github.com/node-inspector/node-inspector/issues/698

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM