无法在Windows 7,10

时间:2018-07-10 13:18:38

标签: angular karma-runner

我正在尝试为Angular应用程序执行单元测试,但是在Windows(7和10)下启动Karma测试时遇到问题。执行“ ng test”命令后,Karma开始编译,然后Chrome浏览器打开并尝试找到http://localhost:9876/?id=84122006。但是什么也没发生。然后在60000毫秒后发出一条消息“ Chrome在60000毫秒内没有捕获铬,正在杀死”,然后经过两次类似的尝试,它停止了。

我在互联网上发现了很多类似的问题,但是到目前为止似乎还没有找到特定的解决方案。

我尝试了以下操作:

  • 使用Firefox而不是Chrome
  • 在Chrome中使用了--no-sandbox标志
  • 安装了最新的Karma 2.0.4
  • 添加了环境变量NO_PROXY =“ localhost,0.0.0.0/4201,0.0.0.0/9876”
  • 在两台不同的计算机上尝试过:一台使用Windows 7,另一台使用 Windows 10

以上任何措施均未导致任何结果。还是一样-浏览器启动,但是什么也没发生。

有人解决了这个问题吗?

提前感谢您的帮助!

我正在使用Node v8.9.3

我的package.json内容

{
"name": "con-fusion",
"version": "0.0.0",
"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.4",
    "@angular/cdk": "^6.2.1",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/material": "^6.2.1",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "ngx-restangular": "^3.0.0",
    "rxjs": "^6.0.0",
    "rxjs-compat": "^6.2.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.8",
    "@angular/cli": "~6.0.8",
    "@angular/compiler-cli": "^6.0.3",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-firefox-launcher": "^1.1.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

karma.conf.js的内容

module.exports = function (config) {
  config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
  require('karma-jasmine'),
  require('karma-chrome-launcher'),
  require('karma-jasmine-html-reporter'),
  require('karma-coverage-istanbul-reporter'),
  require('@angular-devkit/build-angular/plugins/karma')
],
client: {
  clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
  dir: require('path').join(__dirname, '../coverage'),
  reports: ['html', 'lcovonly'],
  fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
  });
};

0 个答案:

没有答案