运行业力启动时获取找不到入口点

问题描述 投票:0回答:1

我正在编写角度项目的单元测试。

使用中

业力打字稿

我收到错误:

未捕获的错误:找不到入口点[D:/Projects/pmreport-phase-2/PMReport-Prj/PMReportClient/pmreport-web/ngapp/src/app/main/customer/detail/detail.component.spec。 ts](由commonjs.js要求)在node_modules / karma-typescript / dist / client / commonjs.js:13:17

我正在尝试用gg进行研究,但无法解决此问题。

我的代码:

业力配置:

// Karma configuration
// Generated on Mon Feb 03 2020 17:18:41 GMT+0700 (Indochina Time)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    plugins : [
      'karma-typescript',
      'karma-chrome-launcher'
    ],
    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['karma-typescript'],


    // list of files / patterns to load in the browser
    files: [
      {pattern : 'src/**/*.spec.ts',included:true},
      {pattern : 'src/**/*.spec.ts',included:false}
    ],
    karmaTypescriptConfig : {
      bundlerOptions: {
        entrypoints: /\.spec\.ts$/
      },
      compilerOptions : {
        module : "commonjs"
      },
      tsconfig : "./tsconfig.json",
    },

    // list of files / patterns to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      "**/*.spec.ts":"karma-typescript"
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress','karma-typescript'],



    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
};

测试文件:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DetailCustomerComponent } from "./detail.component";


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

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

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

    it('should create', () => {
        expect(component).toBeTruthy();
    });
});

在这种情况下,您能帮我吗?我将非常感谢

感谢您的时间

angular karma-runner karma-typescript
1个回答
0
投票

尝试以下配置选项:

frameworks: ["jasmine", "karma-typescript"],

files: [
    { pattern: "src/**/*.ts" }
],

preprocessors: {
    "**/*.ts": ["karma-typescript"]
}
© www.soinside.com 2019 - 2024. All rights reserved.