No Description

karma.conf.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. 'use strict';
  2. var ip = require('ip');
  3. var browserConfig = require('./browsers');
  4. var browserStack = process.env.BROWSER === 'true';
  5. module.exports = function (config) {
  6. var conf = {
  7. basePath: '../',
  8. frameworks: ['qunit'],
  9. plugins: ['karma-qunit'],
  10. // list of files / patterns to load in the browser
  11. files: [
  12. 'js/tests/vendor/jquery.min.js',
  13. 'js/tooltip.js',
  14. 'js/!(tooltip).js',
  15. 'js/tests/unit/*.js'
  16. ],
  17. reporters: ['dots'],
  18. port: 9876,
  19. colors: true,
  20. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  21. logLevel: config.LOG_ERROR || config.LOG_WARN,
  22. autoWatch: false,
  23. singleRun: true,
  24. concurrency: Infinity,
  25. client: {
  26. qunit: {
  27. showUI: true
  28. }
  29. }
  30. };
  31. if (browserStack) {
  32. conf.hostname = ip.address();
  33. conf.browserStack = {
  34. username: process.env.BROWSER_STACK_USERNAME,
  35. accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
  36. build: 'bootstrap-v3-' + new Date().toISOString(),
  37. project: 'Bootstrap v3',
  38. retryLimit: 1
  39. };
  40. conf.plugins.push('karma-browserstack-launcher');
  41. conf.customLaunchers = browserConfig.list;
  42. conf.browsers = browserConfig.keys;
  43. conf.reporters.push('BrowserStack');
  44. } else {
  45. conf.frameworks.push('detectBrowsers');
  46. conf.plugins.push(
  47. 'karma-chrome-launcher',
  48. 'karma-firefox-launcher',
  49. 'karma-detect-browsers'
  50. );
  51. conf.detectBrowsers = {
  52. usePhantomJS: false,
  53. postDetection: function (availableBrowser) {
  54. if (typeof process.env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) {
  55. return ['ChromeHeadless'];
  56. }
  57. if (availableBrowser.includes('Firefox')) {
  58. return ['FirefoxHeadless'];
  59. }
  60. throw new Error('Please install Firefox or Chrome');
  61. }
  62. };
  63. conf.customLaunchers = {
  64. FirefoxHeadless: {
  65. base: 'Firefox',
  66. flags: ['-headless']
  67. }
  68. };
  69. }
  70. config.set(conf);
  71. };