Запуск кармы с помощью теста ng дает ошибку: порождает EPERM на ChildProcess.spawn - PullRequest
0 голосов
/ 03 июля 2019

Когда я пытаюсь запустить ng test с karma и jasmine, я сталкиваюсь с этой проблемой:

нг тест

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 и другие проблемы с версиями пакета, но безрезультатно.
  • Попытка запуска ng test в PowerShell с правами администратора тоже не помогает.
  • Также, если кто-то еще проверяет проект и пытается запустить ng test, он работает нормально (Win 10)
  • Я пробовал с помощью Chrome и Firefox launcher

Так что я подозреваю, что есть более серьезная проблема, связанная с запуском браузера из моей файловой системы.

Файл конфигурации Karma:

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"
  }
...