javascript – SystemJS Karma TypeScript – 未运行测试

前端之家收集整理的这篇文章主要介绍了javascript – SystemJS Karma TypeScript – 未运行测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图运行一些单元测试几天,现在没有成功.我的应用程序是用typcript写的(单元测试也是用typcript写的).
这是我的业务配置文件
module.exports = function (config) {
  config.set({

    basePath: "../../../../",frameworks: [
      "jasmine","systemjs"
    ],browsers: ['PhantomJS'],singleRun: true,reporters: ['progress'],systemjs: {
      config: {
        paths: {
          systemjs: "src/main/webapp/static/js/engage/lib/bower/system.js/dist/system.src.js",typescript: "build/node_modules/typescript/lib/typescript.js"
        },transpiler: "typescript"
      },// testFileSuffix: ".spec.ts"
    },files: [
      'src/main/webapp/static/js/engage/dist/vendor/vendor.min.js','src/main/webapp/static/js/engage/lib/bower/system.js/dist/system-polyfills.src.js','src/main/webapp/static/js/engage/lib/bower/angular-mocks/angular-mocks.js',{pattern: "src/main/webapp/static/js/engage/app/**/*.spec.ts",served: true,included: false}
    ]
  });
};

当我运行业务开始时,我会收到以下错误

05 09 2016 21:39:45.543:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
05 09 2016 21:39:45.546:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
05 09 2016 21:39:45.558:INFO [launcher]: Starting browser PhantomJS
05 09 2016 21:39:47.631:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket /#c-ZoxCczyYymPDAtAAAA with id 8911412
05 09 2016 21:39:47.650:WARN [web-server]: 404: /base/src/main/webapp/static/js/engage/lib/bower/system.js/dist/system-polyfills.js
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!

如果我将浏览器属性更改为Chrome,我会收到以下错误

Chrome 52.0.2743 (Mac OS X 10.11.6) ERROR
  Error: ReferenceError: jasmineRequire is not defined
            at eval (build/node_modules/karma-jasmine/lib/boot.js:14:32)
            at eval (build/node_modules/karma-jasmine/lib/boot.js:41:2)
        Evaluating build/node_modules/karma-jasmine/lib/boot.js
        Error loading build/node_modules/karma-jasmine/lib/boot.js

这是我的package.json相关依赖:

"phantomjs": "^1.9.11","karma-systemjs": "^0.14.0","karma-jasmine": "^1.0.2","karma-chrome-launcher": "^0.1.5","jasmine-core": "^2.5.0"

任何帮助将不胜感激!

解决方法

>我将尝试将systemjs作为第一个框架包含在文档中
>在将它加载到systemjs之前编译你的typescript,不要使用systemjs typescript compile.这将降低您的业力测试的复杂性,使其更加坚实
>尝试将包含的内容更改为您的规格文件,这有助于我解决一些问题.但我不知道那个
把你的basePath放在./,因为这只是让麻烦
>检查您的system.js的路径,因为它会引发404错误

我的system.js配置看起来像这样

systemjs: {
    configFile: 'dev/systemjs.config.js',config: {
        map: {
            'systemjs':          'node_modules/systemjs/dist/system.js','system-polyfills':  'node_modules/systemjs/dist/system-polyfills.js','es6-module-loader': 'node_modules/es6-module-loader/dist/es6-module-loader.js'
        }
    }
}

也许这个问题的一些配置片段可能有帮助:
Angular 2 + Karma + karma-jspm + karma-coverage + typescript report phantomJS failure

原文链接:https://www.f2er.com/js/153521.html

猜你在找的JavaScript相关文章