茉莉花html加载器没有加载角度4 webpack

时间:2018-01-18 11:01:02

标签: angular karma-runner karma-jasmine karma-webpack

我正在尝试单位测试我的角度应用程序。我是新karama测试我正在尝试业力,茉莉和量角器..我已下载和所有业力依赖。我在视觉工作室2017使用角webpack版本。我正面临一些问题,如

1.karma html loader没有加载,只有我能看到karma v1.7.0被连接,而调试在karma浏览器中出现模块错误但是应用程序运行良好

2.i已完成组件测试但显示错误..在CLI版本中正在运行

3.我已经下载了量角器我需要手动添加protractor.js吗?

4.如何在webpack版本中配置karma以获取html视图

my pakage.json

   {
 "name": "EfficiencyClassWebApp",
  "private": true,
   "version": "0.0.0",
    "scripts": {
       "test": "karma start ClientApp/test/karma.conf.js"
           },
            "dependencies": {
           "@angular/animations": "4.2.5",
       "@angular/common": "4.2.5",
     "@angular/compiler": "4.2.5",
     "@angular/compiler-cli": "4.2.5",
     "@angular/core": "4.2.5",
     "@angular/forms": "4.2.5",
     "@angular/http": "4.2.5",
     "@angular/platform-browser": "4.2.5",
    "@angular/platform-browser-dynamic": "4.2.5",
    "@angular/platform-server": "4.2.5",
    "@angular/router": "4.2.5",
    "@ngtools/webpack": "1.5.0",
    "@types/webpack-env": "1.13.0",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
   "aspnet-webpack": "^2.0.1",
   "awesome-typescript-loader": "3.2.1",
   "bootstrap": "3.3.7",
    "css": "2.2.1",
    "css-loader": "0.28.4",
    "csvtojson": "^1.1.9",
    "es6-shim": "0.35.3",
   "event-source-polyfill": "0.0.9",
    "expose-loader": "0.7.3",
   "extract-text-webpack-plugin": "2.1.2",
    "file-loader": "0.11.2",
   "html-loader": "0.4.5",
    "isomorphic-fetch": "2.2.1",
    "jquery": "3.2.1",
    "json-loader": "0.5.4",
    "ngx-papaparse": "^1.2.5",
    "preboot": "4.5.2",
    "primeng": "^5.0.0",
   "raw-loader": "0.5.1",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.4.2",
    "style-loader": "0.18.2",
    "to-string-loader": "1.1.5",
    "toastr-ng2": "^4.1.1",
     "typescript": "2.4.1",
     "url-loader": "0.5.9",
      "web-animations-js": "^2.3.1",
     "webpack": "2.5.1",
     "webpack-hot-middleware": "2.18.2",
     "webpack-merge": "4.1.0",
    "zone.js": "0.8.12"
    },
  "devDependencies": {
   "@types/chai": "4.0.1",
    "@types/jasmine": "2.5.53",
   "@types/rx": "^4.1.1",
    "chai": "4.0.2",
  "jasmine-core": "2.6.4",
     "karma": "1.7.0",
 "karma-chai": "0.1.0",
   "karma-chrome-launcher": "2.2.0",
   "karma-cli": "1.0.1",
   "karma-jasmine": "1.1.0",
    "karma-webpack": "2.0.3",
    "protractor-webpack": "^1.1.0",
    "webpack": "1.13.1",
   "html-loader": "0.4.3",
    "babel-loader": "5.3.2",
    "html-webpack-plugin": "1.6.1",
    "rimraf": "^2.5.3",
    "run-sequence": "1.1.2",
    "karma-coverage": "^0.5.3",
    "loader-utils": "^0.2.12",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-mocha-reporter": "^2.2.2",
    "karma-remap-istanbul": "^0.6.0"


   }
  }

karma.config.js

       module.exports = function (config) {
      config.set({
    basePath: '.',
    frameworks: ['jasmine'],
    files: [
        '../../wwwroot/dist/vendor.js',
        './boot-tests.ts'
    ],
    preprocessors: {
        './boot-tests.ts': ['webpack']
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    mime: { 'application/javascript': ['ts','tsx'] },
    singleRun: false,
    webpack: require('../../webpack.config.js')().filter(config => 
       config.target !== 'node'), // Test against client bundle, because 
  tests run in a 
   browser
    webpackMiddleware: { stats: 'errors-only' }
   });
      };

我的spec.ts / component test

                           import { async, ComponentFixture, TestBed } from 
                '@angular/core/testing';
  import { } from 'jasmine';
    import { ManageMarketComponent } from './marketdetails.component';

   describe('ManageMarketComponent', () => {
   let component: ManageMarketComponent;
   let fixture: ComponentFixture<ManageMarketComponent>;

     beforeEach(async(() => {
              TestBed.configureTestingModule({
        declarations: [ManageMarketComponent]
    })
        .compileComponents();
   }));

   beforeEach(() => {
    fixture = TestBed.createComponent(ManageMarketComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
   });

  it('ManageMarketComponent  is created ', () => {
    expect(component).toBeTruthy();
  });


   });

0 个答案:

没有答案