使用Stryker进行角突变测试,为什么stryker启动浏览器:未定义?

时间:2018-12-19 17:01:44

标签: angular phantomjs karma-runner mutation-testing stryker

我想用stryker对我的棱角项目进行突变测试。

我尝试将代码放入以下仓库中:https://github.com/nicojs/angular-stryker-example

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-phantomjs-launcher'),
      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', 'lcov', 'cobertura'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.DEBUG,
    autoWatch: false,
    browsers: ['PhantomJS'],
    singleRun: true,
    customLaunchers: {
      ChromeHeadless: {
        base: 'Chrome',
        flags: [
          '--headless',
          '--disable-gpu',
          '--no-sandbox',
          // Without a remote debugging port, Google Chrome exits immediately.
          '--remote-debugging-port=9222',
        ],
      }
    }
  });
};

Stryker.conf.js:

const getProjectDetails = require('@angular/cli/utilities/project').getProjectDetails;
const appConfig = getProjectDetails();

module.exports = function (config) {
  config.set({
    mutate: [
      'src/app/*.component.ts'
    ],
    testRunner: 'karma',
    maxConcurrentTestRunners: 4,
    mutator: 'typescript',
    transpilers: ['webpack'],
    reporter: ['html', 'clear-text', 'progress'],
    testFramework: 'jasmine',
    coverageAnalysis: 'off',
    karmaConfig: {
      //configFile: 'karma.conf.js',
      frameworks: ['jasmine'],
      customContextFile: require.resolve('@angular-devkit/build-angular/src/angular-cli-files/plugins/karma-context.html'),
      customDebugFile: require.resolve('@angular-devkit/build-angular/src/angular-cli-files/plugins/karma-debug.html'),
      plugins: [
        require.resolve('karma-jasmine'),
        require('karma-phantomjs-launcher'),
      ],
      proxies: {
        "/_karma_webpack_/": "/base/dist/"
      },
      files: [
        { pattern: 'dist/*.js', included: false }
      ],
      browsers: ['PhantomJS']
    },
    tsconfigFile: 'tsconfig.json',
    webpack: {
      configFile: 'webpack-stryker.conf.js'
    },
    logLevel: 'info'
  });
};

Package.json:

{
  "name": "wereldwijde-weerweddenschappen",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test --browsers PhantomJS --code-coverage",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "stryker": "stryker run",
    "postinstall": "node patch.js",
    "trufflecompile": "truffle compile",
    "truffle-test": "truffle.cmd test test/with-oraclize-test.js"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.0.0",
    "@angular/cdk": "7.0.2",
    "@angular/common": "6.1.7",
    "@angular/compiler": "6.1.7",
    "@angular/core": "6.1.7",
    "@angular/forms": "6.1.7",
    "@angular/http": "6.1.7",
    "@angular/material": "7.0.2",
    "@angular/platform-browser": "6.1.7",
    "@angular/platform-browser-dynamic": "6.1.7",
    "@angular/platform-server": "6.1.7",
    "@angular/router": "6.1.7",
    "arr-flatten": "1.1.0",
    "chai": "4.2.0",
    "core-js": "2.5.4",
    "ganache-cli": "6.2.3",
    "hammerjs": "2.0.8",
    "intl": "1.2.5",
    "isarray": "2.0.4",
    "phantomjs": "2.1.7",
    "phantomjs-prebuilt": "2.1.16",
    "solidity-coverage": "0.5.11",
    "truffle-assertions": "0.7.1",
    "tslint-sonarts": "^1.8.0",
    "web3": "1.0.0-beta.36",
    "web3-utils": "1.0.0-beta.36",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.1",
    "@angular/cli": "~6.0.1",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "angular2-template-loader": "^0.6.2",
    "awesome-typescript-loader": "^5.0.0",
    "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-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-ng-scenario": "^1.0.0",
    "karma-phantomjs-launcher": "1.0.4",
    "protractor": "~5.3.0",
    "stryker": "^0.24.0",
    "stryker-api": "^0.17.1",
    "stryker-html-reporter": "^0.14.1",
    "stryker-karma-runner": "^0.15.1",
    "stryker-typescript": "^0.11.1",
    "stryker-webpack-transpiler": "^0.5.0",
    "truffle": "4.1.12",
    "truffle-contract": "3.0.4",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

我未更改webpack-stryker.conf.js

我希望我的突变测试能够运行,但是出现以下错误:

Launching browser PhantomJS with unlimited concurrency
Starting browser undefined
 TypeError: _.forOwn is not a function
    at runnerOptions.strykerOptions.karmaConfig.plugins.launcher:PhantomJS._start (eval at deserialize <project_folder>\node_modules\surrial\src\index.js:16:18)

有人知道为什么它说启动浏览器未定义以及为什么找不到它的功能吗?

0 个答案:

没有答案