在Visual Studio 2015测试资源管理器'中,获取消息:未捕获的语法错误:意外的令牌导入

时间:2016-07-19 13:25:33

标签: javascript angularjs visual-studio-2015 karma-jasmine

我在Visual Studio 2015更新2中使用Karma,Jasmine为我的应用程序运行单元测试。

我使用过Karma测试适配器'这样做。

我的Karma.conf.js是:

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'],


    // list of files / patterns to load in the browser
    files: [
      { pattern: 'src/test/app.component.spec.js', included: true },
      { pattern: 'src/**/*spec.ts', included: false },
      { pattern: 'src/**/**/*spec.ts', included: false },
      { pattern: 'src/**/**/**/*spec.ts', included: false },
       { pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: false },
      { pattern: 'node_modules/zone.js/dist/long-stack-trace-zone.js', included: true, watched: false },
      { pattern: 'node_modules/zone.js/dist/async-test.js', included: true, watched: false },
      { pattern: 'node_modules/zone.js/dist/jasmine-patch.js', included: true, watched: false },
      { pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: false },
      { pattern: 'node_modules/@angular/**/*.js', included: false, watched: false },
      { pattern: 'src/**/*.spec.ts', included: true },
      { pattern: 'node_modules/systemjs/dist/system.src.js', included: true },
      { pattern: 'node_modules/core-js/client/shim.min.js', included:true }
    ],


    // 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: {
    },


    // 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: 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 {AppComponent} from './app.component';
describe('Test Search in InSite', () => {
var cc = new AppComponent();
it('Data Enquiry should return something', 
() => {expect(cc.search()).toBe("Helloo"); });
});

我的Package.json是:

  

{ "name": "angular2-webpack", "version": "1.0.0", "description": "Angular 2", "main": "index.js", "scripts": { "dev": "webpack-dev-server --history-api-fallback --content-base ./src --open", "postinstall": "rm -rf typings && typings install && npm run webdriver-update", "test": "karma start karma.conf.js", "webdriver-update": "webdriver-manager update", "typings": "typings" }, "author": "", "license": "SEE LICENSE IN LICENSE", "dependencies": { "@angular/common": "^2.0.0-rc.1", "@angular/compiler": "^2.0.0-rc.1", "@angular/core": "^2.0.0-rc.1", "@angular/http": "^2.0.0-rc.1", "@angular/platform-browser": "^2.0.0-rc.1", "@angular/platform-browser-dynamic": "^2.0.0-rc.1", "@angular/router": "3.0.0-alpha.6", "es6-shim": "^0.35.0", "reflect-metadata": "^0.1.2", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12", "require": "^2.4.20", "requirejs": "^2.2.0" }, "devDependencies": { "babel-core": "^6.3.17", "babel-loader": "^6.2.0", "codelyzer": "^0.0.23", "copy-webpack-plugin": "^3.0.0", "css-loader": "^0.23.0", "file-loader": "^0.8.4", "jasmine": "^2.4.1", "jasmine-core": "^2.4.1", "json-loader": "^0.5.4", "karma": "^0.13.15", "karma-chrome-launcher": "^1.0.0", "karma-jasmine": "^1.0.0", "karma-mocha-reporter": "^2.0.0", "karma-phantomjs-launcher": "^1.0.1", "karma-sourcemap-loader": "^0.3.6", "karma-vs-reporter": "^0.8.0", "protractor": "^3.0.0", "raw-loader": "^0.5.1", "stylus": "^0.54.2", "stylus-loader": "^2.0.0", "ts-loader": "^0.8.0", "tslint": "^3.10.2", "tslint-loader": "^2.1.4", "typescript": "^1.7.3", "typings": "^1.0.0", "webpack": "^2.1.0-beta.13", "webpack-dev-server": "^2.1.0-beta.0" } }   我收到错误'消息:未捕获的SyntaxError:意外的令牌导入'在测试资源管理器请让我解决。

先谢谢 -Saggy

0 个答案:

没有答案