{"action":"opened","issue":{"url":"https://api.github.com/repos/mgechev/angular2-seed/issues/982","repository_url":"https://api.github.com/repos/mgechev/angular2-seed","labels_url":"https://api.github.com/repos/mgechev/angular2-seed/issues/982/labels{/name}","comments_url":"https://api.github.com/repos/mgechev/angular2-seed/issues/982/comments","events_url":"https://api.github.com/repos/mgechev/angular2-seed/issues/982/events","html_url":"https://github.com/mgechev/angular2-seed/issues/982","id":159762697,"number":982,"title":"Using Mocha and Chai instead of Jasmine is not working","user":{"login":"ghudeihed","id":169615,"avatar_url":"https://avatars.githubusercontent.com/u/169615?v=3","gravatar_id":"","url":"https://api.github.com/users/ghudeihed","html_url":"https://github.com/ghudeihed","followers_url":"https://api.github.com/users/ghudeihed/followers","following_url":"https://api.github.com/users/ghudeihed/following{/other_user}","gists_url":"https://api.github.com/users/ghudeihed/gists{/gist_id}","starred_url":"https://api.github.com/users/ghudeihed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghudeihed/subscriptions","organizations_url":"https://api.github.com/users/ghudeihed/orgs","repos_url":"https://api.github.com/users/ghudeihed/repos","events_url":"https://api.github.com/users/ghudeihed/events{/privacy}","received_events_url":"https://api.github.com/users/ghudeihed/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-11T08:21:27Z","updated_at":"2016-06-11T08:21:27Z","closed_at":null,"body":"I installed karma-mocha and karma-chai and modified karma.config.js as the following: \r\n`// Karma configuration\r\n// Generated on Wed Jul 15 2015 09:44:02 GMT+0200 (Romance Daylight Time)\r\n'use strict';\r\n\r\nvar argv = require('yargs').argv;\r\n\r\nmodule.exports = function(config) {\r\n  config.set({\r\n\r\n    // base path that will be used to resolve all patterns (eg. files, exclude)\r\n    basePath: './',\r\n\r\n\r\n    // frameworks to use\r\n    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter\r\n    frameworks: [//'jasmine',\r\n                 'mocha',\r\n                 'chai',\r\n                 'sinon'\r\n                 ],\r\n\r\n\r\n    // list of files / patterns to load in the browser\r\n    files: [\r\n      // Polyfills.\r\n      'node_modules/core-js/client/shim.min.js',\r\n\r\n      // System.js for module loading\r\n      'node_modules/systemjs/dist/system-polyfills.js',\r\n      'node_modules/systemjs/dist/system.src.js',\r\n\r\n      // Zone.js dependencies\r\n      'node_modules/zone.js/dist/zone.js',\r\n      //'node_modules/zone.js/dist/jasmine-patch.js',\r\n      'node_modules/zone.js/dist/async-test.js',\r\n      'node_modules/zone.js/dist/fake-async-test.js',\r\n      \r\n      // Chai.js\r\n      'node_modules/chai-angular/chai-angular.js',\r\n\r\n      // RxJs.\r\n      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },\r\n      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },\r\n\r\n      // paths loaded via module imports\r\n      // Angular itself\r\n      { pattern: 'node_modules/@angular/**/*.js', included: false, watched: true },\r\n\r\n      { pattern: 'dist/dev/**/*.js', included: false, watched: true },\r\n      { pattern: 'dist/dev/**/*.html', included: false, watched: true, served: true },\r\n      { pattern: 'dist/dev/**/*.css', included: false, watched: true, served: true },\r\n      { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: false, watched: false }, // PhantomJS2 (and possibly others) might require it\r\n\r\n      // suppress annoying 404 warnings for resources, images, etc.\r\n      { pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },\r\n\r\n      'test-main.js'\r\n    ],\r\n\r\n    // must go along with above, suppress annoying 404 warnings.\r\n    proxies: {\r\n      '/assets/': '/base/dist/dev/assets/'\r\n    },\r\n\r\n    // list of files to exclude\r\n    exclude: [\r\n      'node_modules/**/*spec.js'\r\n    ],\r\n\r\n\r\n    // preprocess matching files before serving them to the browser\r\n    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor\r\n    preprocessors: {\r\n      'dist/**/!(*spec).js': ['coverage']\r\n    },\r\n\r\n    // test results reporter to use\r\n    // possible values: 'dots', 'progress'\r\n    // available reporters: https://npmjs.org/browse/keyword/karma-reporter\r\n    reporters: ['mocha', 'coverage'],\r\n\r\n\r\n    // web server port\r\n    port: 9876,\r\n\r\n\r\n    // enable / disable colors in the output (reporters and logs)\r\n    colors: true,\r\n\r\n\r\n    // level of logging\r\n    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG\r\n    logLevel: config.LOG_INFO,\r\n\r\n\r\n    // enable / disable watching file and executing tests whenever any file changes\r\n    autoWatch: true,\r\n\r\n\r\n    plugins: [\r\n      //'karma-jasmine',\r\n      'karma-chai',\r\n      'karma-sinon',\r\n      'karma-mocha',\r\n      'karma-coverage',\r\n      'karma-mocha-reporter',\r\n      'karma-chrome-launcher',\r\n      'karma-phantomjs-launcher'\r\n    ],\r\n\r\n\r\n    // start these browsers\r\n    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher\r\n    browsers: [\r\n      'PhantomJS',\r\n      'Chrome'\r\n    ],\r\n\r\n\r\n    customLaunchers: {\r\n      Chrome_travis_ci: {\r\n        base: 'Chrome',\r\n        flags: ['--no-sandbox']\r\n      }\r\n    },\r\n\r\n    coverageReporter: {\r\n      dir: 'coverage/',\r\n      reporters: [\r\n        { type: 'text-summary' },\r\n        { type: 'json', subdir: '.', file: 'coverage-final.json' },\r\n        { type: 'html' }\r\n      ]\r\n    },\r\n\r\n    // Continuous Integration mode\r\n    // if true, Karma captures browsers, runs the tests and exits\r\n    singleRun: false,\r\n\r\n    // Passing command line arguments to tests\r\n    client: {\r\n      files: argv.files,    \r\n      chai: {\r\n        includeStack: true\r\n      }\r\n    }\r\n  });\r\n\r\n  if (process.env.APPVEYOR) {\r\n    config.browsers = ['IE'];\r\n    config.singleRun = true;\r\n    config.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough\r\n  }\r\n\r\n  if (process.env.TRAVIS || process.env.CIRCLECI) {\r\n    config.browsers = ['Chrome_travis_ci'];\r\n    config.singleRun = true;\r\n  }\r\n};\r\n`\r\n\r\nI also modified test-main.js \r\n`if (!Object.hasOwnProperty('name')) {\r\n  Object.defineProperty(Function.prototype, 'name', {\r\n    get: function() {\r\n      var matches = this.toString().match(/^\\s*function\\s*(\\S*)\\s*\\(/);\r\n      var name = matches && matches.length > 1 ? matches[1] : \"\";\r\n      Object.defineProperty(this, 'name', {value: name});\r\n      return name;\r\n    }\r\n  });\r\n}\r\n\r\n// Turn on full stack traces in errors to help debugging\r\nError.stackTraceLimit = Infinity;\r\n\r\n// jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;\r\n\r\n// Cancel Karma's synchronous start,\r\n// we will call `__karma__.start()` later, once all the specs are loaded.\r\n__karma__.loaded = function() {};\r\n\r\n// Load our SystemJS configuration.\r\nSystem.config({\r\n  baseURL: '/base/'\r\n});\r\n\r\nSystem.config({\r\n  defaultJSExtensions: true,\r\n  map: {\r\n    'rxjs': 'node_modules/rxjs',\r\n    '@angular': 'node_modules/@angular'\r\n  },\r\n  packages: {\r\n    '@angular/core': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/compiler': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/common': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/http': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/platform-browser': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/platform-browser-dynamic': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    '@angular/router': {\r\n      main: 'index.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    'angular2-lockor/lib': {\r\n      main: 'locker.js',\r\n      defaultExtension: 'js'\r\n    },\r\n    'rxjs': {\r\n      defaultExtension: 'js'\r\n    }\r\n  }\r\n});\r\n\r\nPromise.all([\r\n  System.import('@angular/core/testing'),\r\n  System.import('@angular/platform-browser-dynamic/testing')\r\n]).then(function (providers) {\r\n  var testing = providers[0];\r\n  var testingBrowser = providers[1];\r\n\r\n  testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,\r\n    testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);\r\n\r\n}).then(function() {\r\n  return Promise.all(\r\n    Object.keys(window.__karma__.files) // All files served by Karma.\r\n    .filter(onlySpecFiles)\r\n    .map(file2moduleName)\r\n    .map(function(path) {\r\n      return System.import(path).then(function(module) {\r\n        if (module.hasOwnProperty('main')) {\r\n          module.main();\r\n        } else {\r\n          throw new Error('Module ' + path + ' does not implement main() method.');\r\n        }\r\n      });\r\n    }));\r\n})\r\n.then(function() {\r\n  __karma__.start();\r\n}, function(error) {\r\n  console.error(error.stack || error);\r\n  __karma__.start();\r\n});\r\n\r\nfunction onlySpecFiles(path) {\r\n  // check for individual files, if not given, always matches to all\r\n  var patternMatched = __karma__.config.files ?\r\n    path.match(new RegExp(__karma__.config.files)) : true;\r\n\r\n  return patternMatched && /[\\.|_]spec\\.js$/.test(path);\r\n}\r\n\r\n// Normalize paths to module names.\r\nfunction file2moduleName(filePath) {\r\n  return filePath.replace(/\\\\/g, '/')\r\n    .replace(/^\\/base\\//, '')\r\n    .replace(/\\.js$/, '');\r\n}\r\n`\r\nI added typings for both mocha and chai in the typings.json file and removed the jasmine typings. \r\n\r\nnow I run the gulp test task I get 0 test run and no code coverage\r\n\r\nanybody can tell me what am I doing wrong here, I have been trying to get it to work all day but no luck getting any result."}}
{"actor":{"display_login":"ghudeihed"}}