Получение Не удается найти точку входа при запуске karma start

Я пишу модульный тест для углового проекта.

С использованием

карма-машинопись

.

И я получил ошибку:

Неперехваченная ошибка: не удается найти точку входа [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();
    });
});

Можете ли вы помочь мне в этом случае? Я был бы очень признателен

Спасибо за ваше время


person Vũ Minh Vương    schedule 04.02.2020    source источник


Ответы (1)


Попробуйте следующие параметры конфигурации:

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

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

preprocessors: {
    "**/*.ts": ["karma-typescript"]
}
person Akash Bhardwaj    schedule 04.02.2020
comment
Возникла ошибка в afterAll Uncaught ReferenceError: Зона не определена ReferenceError: Зона не определена - person Vũ Minh Vương; 04.02.2020
comment
Я думаю, вам нужно добавить zone.js в ваш массив файлов. файлы: ['node_modules/zone.js/dist/zone.js'] - person Akash Bhardwaj; 04.02.2020