Angular Karma单元测试错误:您可能需要适当的加载程序来处理此文件类型

Angular Karma单元测试错误:您可能需要适当的加载程序来处理此文件类型,angular,typescript,karma-runner,karma-jasmine,karma-webpack,Angular,Typescript,Karma Runner,Karma Jasmine,Karma Webpack,我正在尝试使用打字脚本(Angular 4)中的Karma和Jasmine进行一些单元测试。我正在从事的项目大部分是由他人完成的(我在一家公司实习),我只开发了其中的一小部分 问题是我需要做一些测试,测试组件,以及任何其他我能做的事情。我没有特殊要求。在尝试这样做时,我遇到了许多问题,其中一个就是下面的问题 我的测试组件 import 'zone.js'; import 'reflect-metadata'; import { async, ComponentFixture, TestBed }

我正在尝试使用打字脚本(Angular 4)中的Karma和Jasmine进行一些单元测试。我正在从事的项目大部分是由他人完成的(我在一家公司实习),我只开发了其中的一小部分

问题是我需要做一些测试,测试组件,以及任何其他我能做的事情。我没有特殊要求。在尝试这样做时,我遇到了许多问题,其中一个就是下面的问题

我的测试组件

import 'zone.js';
import 'reflect-metadata';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { BcsComponent } from '../app/pages/reports/bcs.component';

describe('Testing the Blood culture sets managed component', () => {

let comp: BcsComponent;
//let expectedTitle: string;
//let fixture: ComponentFixture<BcsComponent>;
//let titleEl: DebugElement;

beforeEach(async(() => {
    TestBed.configureTestingModule({
        declarations: [],
    })
        .compileComponents(); // compile template and css
}));

});
有人能帮我解决这个问题吗。我花了两天的时间想弄明白,但没办法。这是我第一次用因果报应做测试

Uncaught Error: Module parse failed: 
C:\TreatUdv\SepsisFinderCore\SepsisFinder\Tests\statistics.component.spec.ts 
Unexpected token (14:12)
You may need an appropriate loader to handle this file type.
| describe('Testing the Blood culture sets managed component', () => {
| 
|     let comp: BcsComponent;
|     //let expectedTitle: string;
|     //let fixture: ComponentFixture<BcsComponent>;
at Object.<anonymous> (statistics.component.spec.ts:70)
at __webpack_require__ (statistics.component.spec.ts:20)
at statistics.component.spec.ts:63
at statistics.component.spec.ts:66
module.exports = function (config) {
  config.set({
      basePath: './',
      frameworks: ['jasmine'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular/cli/plugins/karma'),
      require('karma-webpack'),
    ],
    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in 
browser
    },
coverageIstanbulReporter: {
  reports: [ 'html', 'lcovonly' ],
  fixWebpackSourcePaths: true
},
angularCli: {
  environment: 'dev'
},
mime: {
    'text/x-typescript': ['ts', 'tsx']
},
files: [
    { pattern: './Tests/statistics.component.spec.ts', watched: false },
],
preprocessors: {
    './Tests/statistics.component.spec.ts': ['webpack'],

},
exports: [
    { pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true }
],

reporters: ['progress', 'kjhtml'],
port: 4200,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
  });
};