如何配置Karma

时间:2016-05-20 15:43:15

标签: angular karma-runner

这是我的根目录
  src/tsfolders/.ts files public/src/jsfolders/.js files

和Karma配置

module.exports = function(config) {

config.set({     basePath:'。',     框架:[' jasmine'],     插件:[       要求('果报茉莉&#39),       要求('因缘 - 铬 - 发射&#39),       需要('卡玛HTMLFILE-记者')     ],

customLaunchers: {
  // From the CLI. Not used here but interesting
  // chrome setup for travis CI using chromium
  Chrome_travis_ci: {
    base: 'Chrome',
    flags: ['--no-sandbox']
  }
},
files: [
  // System.js for module loading
  'node_modules/systemjs/dist/system-polyfills.js',
  'node_modules/systemjs/dist/system.src.js',

  // Polyfills
  'node_modules/es6-shim/es6-shim.js',

  // Reflect and Zone.js
  'node_modules/reflect-metadata/Reflect.js',
  'node_modules/zone.js/dist/zone.js',
  'node_modules/zone.js/dist/jasmine-patch.js',
  'node_modules/zone.js/dist/async-test.js',
  'node_modules/zone.js/dist/fake-async-test.js',

  // RxJs.
  { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
  { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

  // Angular 2 itself and the testing library
  {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
  {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},

  'karma-test-shim.js',

   {pattern: 'public/src/**/*.js', included: false, watched: true},

          // paths to support debugging with source maps in dev tools
    {pattern: 'src/**/*.ts', included: false, watched: false},
    {pattern: 'src/**/*.js.map', included: false, watched: false}
],

// proxied base paths for loading assets
proxies: {
  // required for component assets fetched by Angular's compiler
  '/src/': '/base/src/'

},

exclude: [],
preprocessors: {},
reporters: ['progress', 'html'],

// HtmlReporter configuration
htmlReporter: {
  // Open this file to see results in browser
  outputFile: '_test-output/tests.html',

  // Optional
  pageTitle: 'Unit Tests',
  subPageTitle: __dirname
},

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false

}) }

有人可以解释如何配置Karma路径,因为现在它没有看到我的任何测试并返回错误"执行0 of 0 ERROR"

1 个答案:

答案 0 :(得分:0)

Karma将在您的Karma.conf.js文件所在的位置查找相关文件。

因此,如果您的Karma.conf.js文件位于C:\ YourName \ MyApp \ Karma.conf.js

然后放

 { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }

将让Karma看看

C:/YourName/MyApp/node_modules/rxjs/        and beyond