PhantomJS no funciona con Karma en el proyecto Angular2

He creado un proyecto listo para usar con el cli angular (1.0.0-rc1.0.0). Luego instalé el complemento PhantomJS (npm install karma-phantonjs-launcher) Pasos de reproducción:

crear proyecto con angular2 cli (ng new TestPhantomJS)corrernpm install karma-phantonjs-launcheren el archivo karma.conf agregue PhantomJS, es decir, cambie abrowsers: ['Chrome'] estabrowsers:['Chrome', 'PhantomJS']

La razón es que para la integración de Team City necesito un navegador sin cabeza. La prueba funciona bien conng prueba siempre y cuando Chrome esté especificado como navegador, el problema es cuando intentas usar PhantomJS. Obtendrá el error según la imagen a continuación. Mi investigación sugiere que esto tiene que ver con la compatibilidad con PhantomJS y la versión de JavaScript. Sin embargo, no he encontrado una solución a este problema.

¿Alguien más se ha encontrado con esto y posiblemente encontró una solución?

My karma.conf

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-phantomjs-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    files: [
      { pattern: './src/test.ts', watched: false }
    ],
    preprocessors: {
      './src/test.ts': ['@angular/cli']
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    coverageIstanbulReporter: {
      reports: [ 'html', 'lcovonly' ],
      fixWebpackSourcePaths: true
    },
    angularCli: {
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'coverage-istanbul']
              : ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: [ 'PhantomJS'],
    singleRun: false
  });
};

Mi prueba

// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
declare var require: any;

// Prevent Karma from running prematurely.
__karma__.loaded = function () {};

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
  BrowserDynamicTestingModule,
  platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start()

;

Respuestas a la pregunta(3)

Su respuesta a la pregunta