angular5:未捕获的语法错误:意外的令牌{在app.service.ts:1中,用于单元测试

时间:2019-02-03 04:06:46

标签: angular jasmine karma-jasmine

我不断收到此错误Uncaught SyntaxError:意外令牌{每当我尝试运行我的angular5应用程序测试用例时。

karma.config.js

module.exports = function (config) {
    config.set({
        basePath: '.',
        frameworks: ['jasmine', 'karma-typescript'],
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        files: [
            { pattern: './boot-tests.ts' },
            { pattern: '../app/**/*.+(ts|html)' }
        ],
        preprocessors: {
            '**/*.ts': ['webpack', 'karma-typescript']
        },
        karmaTypescriptConfig: {
            bundlerOptions: {
                entrypoints: /\.spec\.ts$/,
                transforms: [
                    require("karma-typescript-angular2-transform")
                ]
            },
            compilerOptions: {
                lib: ["ES2015", "DOM"]
            }
        },
        //proxies: {
          //  "../app/": "/clientApp/app/"
        //},
        coverageReporter: {
            type: 'html',
            dir: 'coverage/'
        },
        reporters: ['progress', 'karma-typescript'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        mime: { 'application/javascript': ['ts', 'tsx'] },
        singleRun: true,
        webpack: require('../../webpack.config.js')().filter(config => config.target !== 'node'), // Test against client bundle, because tests run in a browser
        webpackMiddleware: { stats: 'errors-only' }
    });
};

我如上所述配置了karma.config.js文件。任何想法为什么我会收到此错误。

0 个答案:

没有答案