使用ng测试启动业力会导致错误:在ChildProcess.spawn上生成EPERM

时间:2019-07-03 15:13:23

标签: angular karma-jasmine karma-runner angular8 karma-chrome-launcher

当我尝试使用ng testkarma启动jasmine时,我遇到了这个问题:

ng测试

10% building 2/2 modules 0 active03 07 2019 16:48:19.811:WARN [karma]: No captured browser, open http://localhost:9876/
03 07 2019 16:48:19.965:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9876/
03 07 2019 16:48:19.965:INFO [launcher]: Launching browsers Firefox with concurrency unlimited
03 07 2019 16:48:19.969:INFO [launcher]: Starting browser Firefox
03 07 2019 16:48:19.983:ERROR [karma-server]: Error: spawn EPERM
    at ChildProcess.spawn (internal/child_process.js:394:11)
    at spawn (child_process.js:535:9)
    at spawnWithoutOutput (C:\Projects\Lifeplanner\node_modules\karma\lib\launchers\process.js:169:26)
    at Object.ProcessLauncher._execCommand (C:\Projects\Lifeplanner\node_modules\karma\lib\launchers\process.js:75:21)
    at Object.FirefoxBrowser._start (C:\Projects\Lifeplanner\node_modules\karma-firefox-launcher\index.js:146:10)
    at Object.<anonymous> (C:\Projects\Lifeplanner\node_modules\karma\lib\launchers\process.js:19:10)
    at Object.emit (events.js:205:15)
    at Object.BaseLauncher.start (C:\Projects\Lifeplanner\node_modules\karma\lib\launchers\base.js:53:10)
    at Object.j (C:\Projects\Lifeplanner\node_modules\karma\lib\launcher.js:85:17)
    at Object.setTimeout.bind.j (C:\Projects\Lifeplanner\node_modules\qjobs\qjobs.js:143:18)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {
  errno: 'EPERM',
  code: 'EPERM',
  syscall: 'spawn'
}
Cannot read property 'success' of undefined
TypeError: Cannot read property 'success' of undefined
    at TestCommand.runSingleTarget (C:\Projects\Lifeplanner\node_modules\@angular\cli\models\architect-command.js:199:27)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at TestCommand.runArchitectTarget (C:\Projects\Lifeplanner\node_modules\@angular\cli\models\architect-command.js:211:31)
    at TestCommand.validateAndRun (C:\Projects\Lifeplanner\node_modules\@angular\cli\models\command.js:137:28)
    at Object.runCommand (C:\Projects\Lifeplanner\node_modules\@angular\cli\models\command-runner.js:178:24)
    at default_1 (C:\Projects\Lifeplanner\node_modules\@angular\cli\lib\cli\index.js:32:31)

我在Windows 10上。

  • 我已注释掉所有测试,没有区别
  • 我研究了可能的Angular CLI兼容性和其他软件包版本问题,但无济于事。
  • 试图在具有管理员权限的Powershell中运行ng test,但也无济于事。
  • 如果其他人签出了该项目并尝试运行ng test,它也可以正常运行(Win 10)
  • 我已经尝试过使用Chrome和Firefox启动器

所以我怀疑有一个更深层次的问题与从文件系统启动浏览器有关。

业力配置文件:

module.exports = function (config) {
    config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular-devkit/build-angular'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
            require('karma-firefox-launcher'),
            require('karma-jasmine-html-reporter'),
            require('karma-coverage-istanbul-reporter'),
            require('karma-scss-preprocessor'),
            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'),
            dir: require('path').join(__dirname, './coverage/unittests'),
            reports: ['html', 'lcovonly', 'text-summary'],
            fixWebpackSourcePaths: true
        },
        preprocessers: {
            './src/test.ts': ['@angular/cli'],
            'node_modules/bootstrap/scss': ['scss'],
            './src/assets/scss/screen.scss': ['scss'],
        },
        loaders: ['raw-loader', 'sass-loader'],
        reporters: ['progress', 'kjhtml'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Firefox'],
        singleRun: false,
        restartOnFileChange: true
    });
};

package.json:

  "dependencies": {
    "@angular/animations": "^8.0.2",
    "@angular/common": "^8.0.2",
    "@angular/compiler": "^8.0.2",
    "@angular/core": "^8.0.2",
    "@angular/forms": "^8.0.2",
    "@angular/platform-browser": "^8.0.2",
    "@angular/platform-browser-dynamic": "^8.0.2",
    "@angular/router": "^8.0.2",
    "@ng-bootstrap/ng-bootstrap": "^4.0.0",
    "@ngx-translate/core": "^11.0.0",
    "@ngx-translate/http-loader": "^4.0.0",
    "@types/clone": "^0.1.30",
    "angular2-uuid": "^1.1.1",
    "bootstrap": "^4.0.0",
    "chart.js": "^2.8.0",
    "clone": "^2.1.2",
    "core-js": "~2.5.0",
    "date-fns": "^1.30.0",
    "file-saver": "^2.0.0",
    "hammerjs": "^2.0.8",
    "karma-scss-preprocessor": "^4.0.0",
    "localize-router": "^2.0.0-RC.2",
    "rxjs": "^6.0.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0",
    "@angular/cli": "^8.0.3",
    "@angular/compiler-cli": "^8.0.2",
    "@angular/language-service": "^8.0.2",
    "@types/chart.js": "^2.7.30",
    "@types/file-saver": "^2.0.0",
    "@types/jasmine": "^3.0.0",
    "@types/jasminewd2": "^2.0.0",
    "@types/node": "^6.0.118",
    "codelyzer": "^5.0.1",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.5",
    "karma-firefox-launcher": "^1.1.0",
    "karma-jasmine": "^2.0.0",
    "karma-jasmine-html-reporter": "^1.4.0",
    "node-sass": "^4.12.0",
    "nyc": "^14.1.1",
    "protractor": "^5.4.0",
    "replace-in-file": "^4.1.0",
    "serve": "^6.5.5",
    "ts-node": "^8.3.0",
    "tslint": "^5.17.0",
    "tslint-config-airbnb": "^5.11.1",
    "typescript": "~3.4.5"
  }

0 个答案:

没有答案