1

我的业力配置:

module.exports = function (config) {
    config.set({
        basePath: '.',
        frameworks: ['mocha', 'chai'],
        files: ['test/**/*-test.js'],
        exclude: [],
        preprocessors: {
            '**/*.ts': ['typescript']
        },
        reporters: ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['PhantomJS'],
        singleRun: false,
        concurrency: Infinity,
        plugins: [ 'karma-*' ],
        client: {
            mocha: { ui: 'bdd' }
        },
        typescriptPreprocessor: {
            options: {
                sourceMap: false,
                target: 'es5',
                module: 'commonjs',
                removeComments: true
            },
            transformPath: function(path) {
                return path.replace(/\.ts$/, '.js');
            }
        }
    })
};

和测试文件

// test/app-test.ts
import chai = require('chai');

var expect = chai.expect;

describe('test', () => {
    it('should work', () => {
        expect(true).should.be.true;
    });
});

结果是

空的测试套件。

当我更改为files: ['test/**/*-test.js'],files: ['test/**/*-test.ts'],,结果是:

找不到变量:需要

完整来源在:https ://github.com/Ridermansb/webpackKarmaAngularTypescriptStarter

4

1 回答 1

0
  1. 失踪typings_karma.config.js
  2. 我使用 bdd 风格,所以测试应该是true.should.be.true.
  3. 无需在测试中要求 chai。

在提交0a4a20c7558579f8c6910a6054e872f87ec97203中修复

于 2015-10-27T12:36:18.303 回答