karma.conf.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // Karma configuration
  2. module.exports = function(config) {
  3. /*var customLaunchers = {
  4. sl_chrome_win7: {
  5. base: 'SauceLabs',
  6. browserName: 'chrome',
  7. platform: 'Windows 7'
  8. },
  9. sl_firefox30_linux: {
  10. base: 'SauceLabs',
  11. browserName: 'firefox',
  12. version: '30',
  13. platform: 'Linux'
  14. },
  15. sl_firefox26_linux: {
  16. base: 'SauceLabs',
  17. browserName: 'firefox',
  18. version: 26,
  19. platform: 'Linux'
  20. },
  21. sl_windows7_ie10: {
  22. base: 'SauceLabs',
  23. browserName: 'internet explorer',
  24. platform: 'Windows 7',
  25. version: '10'
  26. },
  27. sl_windows81_ie11: {
  28. base: 'SauceLabs',
  29. browserName: 'internet explorer',
  30. platform: 'Windows 8.1',
  31. version: '11'
  32. },
  33. sl_osxmavericks_safari7: {
  34. base: 'SauceLabs',
  35. browserName: 'safari',
  36. platform: 'OS X 10.9',
  37. version: '7'
  38. },
  39. sl_osxmtnlion_safari6: {
  40. base: 'SauceLabs',
  41. browserName: 'safari',
  42. platform: 'OS X 10.8',
  43. version: '6'
  44. }
  45. };*/
  46. var customLaunchers = {};
  47. var browsers = [];
  48. var useSauce = false;
  49. if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
  50. useSauce = true;
  51. }
  52. if (useSauce && process.env.TEST_BROWSER_NAME && process.env.TEST_BROWSER_NAME != 'PhantomJS') {
  53. var names = process.env.TEST_BROWSER_NAME.split(',');
  54. var platforms = process.env.TEST_BROWSER_OS.split(',');
  55. var versions = [];
  56. if (process.env.TEST_BROWSER_VERSION) {
  57. versions = process.env.TEST_BROWSER_VERSION.split(',');
  58. } else {
  59. versions = [null];
  60. }
  61. for (var i = 0; i < names.length; i++) {
  62. for (var j = 0; j < platforms.length; j++) {
  63. for (var k = 0; k < versions.length; k++) {
  64. var launcher_name = 'sl_' + platforms[j].replace(/[^a-zA-Z0-9]/g, '') + '_' + names[i];
  65. if (versions[k]) {
  66. launcher_name += '_' + versions[k];
  67. }
  68. customLaunchers[launcher_name] = {
  69. base: 'SauceLabs',
  70. browserName: names[i],
  71. platform: platforms[j],
  72. };
  73. if (versions[i]) {
  74. customLaunchers[launcher_name].version = versions[k];
  75. }
  76. }
  77. }
  78. }
  79. browsers = Object.keys(customLaunchers);
  80. } else {
  81. useSauce = false;
  82. browsers = ['PhantomJS'];
  83. }
  84. var my_conf = {
  85. // base path that will be used to resolve all patterns (eg. files, exclude)
  86. basePath: '',
  87. // frameworks to use
  88. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  89. frameworks: ['mocha', 'sinon', 'chai', 'sinon-chai'],
  90. // list of files / patterns to load in the browser (loaded in order)
  91. files: [
  92. 'tests/fake.*.js',
  93. 'tests/assertions.js',
  94. 'include/util.js', // load first to avoid issues, since methods are called immediately
  95. //'../include/*.js',
  96. 'include/base64.js',
  97. 'include/keysym.js',
  98. 'include/keysymdef.js',
  99. 'include/keyboard.js',
  100. 'include/input.js',
  101. 'include/websock.js',
  102. 'include/rfb.js',
  103. 'include/jsunzip.js',
  104. 'include/des.js',
  105. 'include/display.js',
  106. 'tests/test.*.js'
  107. ],
  108. client: {
  109. mocha: {
  110. 'ui': 'bdd'
  111. }
  112. },
  113. // list of files to exclude
  114. exclude: [
  115. '../include/playback.js',
  116. '../include/ui.js'
  117. ],
  118. customLaunchers: customLaunchers,
  119. // start these browsers
  120. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
  121. browsers: browsers,
  122. // preprocess matching files before serving them to the browser
  123. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  124. preprocessors: {
  125. },
  126. // test results reporter to use
  127. // possible values: 'dots', 'progress'
  128. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  129. reporters: ['mocha', 'saucelabs'],
  130. // web server port
  131. port: 9876,
  132. // enable / disable colors in the output (reporters and logs)
  133. colors: true,
  134. // level of logging
  135. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  136. logLevel: config.LOG_INFO,
  137. // enable / disable watching file and executing tests whenever any file changes
  138. autoWatch: false,
  139. // Continuous Integration mode
  140. // if true, Karma captures browsers, runs the tests and exits
  141. singleRun: true,
  142. // Increase timeout in case connection is slow/we run more browsers than possible
  143. // (we currently get 3 for free, and we try to run 7, so it can take a while)
  144. captureTimeout: 240000
  145. };
  146. if (useSauce) {
  147. my_conf.captureTimeout = 0; // use SL timeout
  148. my_conf.sauceLabs = {
  149. testName: 'noVNC Tests (all)',
  150. startConnect: true,
  151. tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
  152. };
  153. }
  154. config.set(my_conf);
  155. };