0

这是我的业力配置

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine', 'traceur'],

    files: [
      'app/**/**/httpMock/httpMock.interceptor.ts',
        'app/**/**/httpMock/httpMock.module.ts',
        'app/**/**/httpMock/httpMock.service.ts',
        'app/**/**/httpMock/httpMock.config.ts'
         ],
     exclude: [
        'modules/**/e2e_test/**',
        'app/**/e2e/**/*.js',
        'thirdparty/pioneer/featureFlag/**/*{t,T}est.js'
    ],

    preprocessors: {
        //'app/**/*.js': ['traceur'],
        '**/*.ts': ['typescript']
    },
    typescriptPreprocessor: {
        options: {
            sourceMap: false,
            target: 'ES5',
            module: 'commonjs',
            noImplicitAny: true,
            noResolve: true,
            removeComments: true,
            concatinateOutput: false
        },
        typings: [ 'typings/tsd.d.ts' ],
        transformPath: function (path) {
            return path.replace(/\.ts$/, '.js');
        }
    },
    browsers: ['Chrome'],
    reporters: ['spec', 'junit'],
    specReporter: { maxLogLines: 5 },
    junitReporter: {
        outputFile: './build/work/jasmine/TEST-results.xml',
        suite: 'COMP'
    },
    port: 9876
});
};

我在 package.Json 中安装了 dev 依赖项,并安装了预处理器插件。

这是包.Json

"angular": "^1.3.5",
"definitely-typed-angular": "^1.0.1",
"karma": "^0.13.7",
"karma-chrome-launcher": "^0.1.4",
"karma-cli": "^0.0.4",
"karma-dart": "^0.2.8",
"karma-jasmine": "^0.2.2",
"karma-junit-reporter": "^0.2.2",
"karma-spec-reporter": "0.0.16",
"karma-traceur-preprocessor": "^0.4.0",
"karma-typescript-preprocessor": "0.0.20",

当我运行测试任务运行程序时,我不确定是什么导致了这个问题。

 13 10 2015 10:19:50.276:ERROR [preprocessor.typescript]: Cannot find module 'angular' and namespace 'ng'.

   at C:/*****.ts

对于所有四个文件。谁能指出什么是错的?

4

1 回答 1

3

你需要提到业力预处理器plugins:[]

config.set({
    frameworks: ['jasmine', 'traceur'],
    ...

    preprocessors: {       
        '**/*.ts': ['typescript']
    },
    plugins: [
        // these are all I am using
        "teamcity",
        "karma-jasmine",

        "karma-sourcemap-loader",

        "karma-junit-reporter",
        "karma-teamcity-reporter",

        "karma-chrome-launcher",
        "karma-phantomjs-launcher",

        // HERE we mention our guilty one
        "karma-typescript-preprocessor"
    ],
}
于 2015-10-13T16:15:04.173 回答