Не удается найти точку входа при запуске кармы - PullRequest
0 голосов
/ 04 февраля 2020

Я пишу юнит-тест для проекта angular.

Использование

karma-typcript

.

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

Неопознанная ошибка: не удается найти точку входа [D: / Projects / pmreport-phase-2 / PMReport-Prj / PMReportClient / pmreport-web / ngapp / src / app / main / customer / detail / detail.component.spe c .ts] (требуется общим js. js) в node_modules / karma-typcript / dist / client / common js. 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();
    });
});

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

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

1 Ответ

0 голосов
/ 04 февраля 2020

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

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

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

preprocessors: {
    "**/*.ts": ["karma-typescript"]
}
...