Node.js Jasmine忽略类型脚本测试文件?

Node.js Jasmine忽略类型脚本测试文件?,node.js,angular,typescript,jasmine,Node.js,Angular,Typescript,Jasmine,这是我第一次和Jasmine一起做项目,我正在学习一个教程,但一开始就遇到了问题 我已经安装了jasmine节点、打字和打字脚本。我还跑了: typings install dt~jasmine --save-dev --global 茉莉花字体 现在我的./spec文件夹中有一个测试文件,如下所示: import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DatePickerCom

这是我第一次和Jasmine一起做项目,我正在学习一个教程,但一开始就遇到了问题

我已经安装了jasmine节点、打字和打字脚本。我还跑了:

typings install dt~jasmine --save-dev --global 
茉莉花字体

现在我的./spec文件夹中有一个测试文件,如下所示:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DatePickerComponent } from '../src/components/via-datepicker.component';
import * as moment from 'moment';

const Moment: any = (<any>moment).default || moment;

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

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

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

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

  it('should open when clicked', () => {
    fixture.debugElement.nativeElement.querySelector('body').click();
    fixture.whenStable().then(() => {
      expect(component.opened);
    });
    component.close();
  });

  describe('While open', () => {
    beforeEach(() => {
      component.open();
    });

    describe('Pressing the "Today\'s date" button', () => {
      it('should set the value of the picker to the current date and close it', () => {
        fixture.debugElement.nativeElement.querySelector('.datepicker-buttons button').click();
        expect(Moment().isSame(component.value, 'day') && Moment().isSame(component.value, 'month'));
        expect(!component.opened);
      });
    });

    describe('Clicking on a date', () => {
      it('should change the value of the picker and close it', () => {
        let oldValue: any = component.value;
        fixture.debugElement.nativeElement.querySelectorAll('.day')[10].click();
        expect(!component.opened);
        expect(!component.value.isSame(oldValue));
      });
    });

  });

});
我得到这个结果:

Finished in 0 seconds
0 tests, 0 assertions, 0 failures, 0 skipped
很明显,我的测试文件被忽略了。或者我错过了一些图书馆?如果是这种情况,我会收到错误消息吗?这里的主要问题是,除了Jasmine出于某种原因似乎没有“看到”测试文件之外,我没有得到关于问题是什么的更多指导


只是想继续我的项目。任何建议都将不胜感激。

您的测试运行人员似乎不知道您正在尝试运行typescript测试。你是否在使用Karma作为你的试跑者?如果是这样,您需要将Typescript文件添加到karma.config文件中,并安装和配置karma.config文件,如下所示。请密切注意添加到框架、文件和预处理器部分的内容

karma.config

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

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


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


    // list of files / patterns to load in the browser
    files: [
        { pattern: "app/tests/**/*.spec.js"}
    ],


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


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


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


    // 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: false,


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

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
    })
};
module.exports = function(config) {
config.set({

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


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


    // list of files / patterns to load in the browser
    files: [
        { pattern: "app/tests/**/*.spec.js"}
    ],


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


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


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


    // 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: false,


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

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