saucelabs.karma.conf.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. 'use strict'
  2. const yaml = require('js-yaml')
  3. const fs = require('fs')
  4. const browsers = {
  5. sl_chrome: {
  6. base: 'SauceLabs',
  7. browserName: 'chrome',
  8. platform: 'Windows 10',
  9. version: '53'
  10. },
  11. sl_firefox: {
  12. base: 'SauceLabs',
  13. browserName: 'firefox',
  14. version: '49'
  15. },
  16. // sl_ios_safari: {
  17. // base: 'SauceLabs',
  18. // browserName: 'iphone',
  19. // platform: 'OS X 10.11',
  20. // version: '9.3'
  21. // },
  22. sl_ie_11: {
  23. base: 'SauceLabs',
  24. browserName: 'internet explorer',
  25. platform: 'Windows 10',
  26. version: '11'
  27. }
  28. }
  29. module.exports = (config) => {
  30. // Use ENV vars or .sauce.yml to get credentials
  31. if (!process.env.SAUCE_USERNAME) {
  32. if (!fs.existsSync('.sauce.yml')) {
  33. console.log(
  34. 'Create a .sauce.yml with your credentials'
  35. )
  36. process.exit(1)
  37. } else {
  38. let sauceConfig = yaml.safeLoad(fs.readFileSync('.sauce.yml', 'utf8'))
  39. process.env.SAUCE_USERNAME = sauceConfig.addons.sauce_connect.username
  40. process.env.SAUCE_ACCESS_KEY = sauceConfig.addons.sauce_connect.access_key
  41. }
  42. }
  43. config.set({
  44. // base path that will be used to resolve all patterns (eg. files, exclude)
  45. basePath: '',
  46. // frameworks to use
  47. // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  48. frameworks: ['jasmine'],
  49. // list of files / patterns to load in the browser
  50. // @TODO: Make this the same across both configs
  51. files: [
  52. 'jspdf.js',
  53. 'plugins/acroform.js',
  54. 'plugins/annotations.js',
  55. 'plugins/split_text_to_size.js',
  56. 'plugins/standard_fonts_metrics.js',
  57. 'plugins/autoprint.js',
  58. 'plugins/addhtml.js',
  59. 'tests/utils/compare.js',
  60. {
  61. pattern: 'tests/**/*.spec.js',
  62. included: true
  63. }, {
  64. pattern: 'tests/**/reference/*.pdf',
  65. included: false,
  66. served: true
  67. }
  68. ],
  69. // list of files to exclude
  70. exclude: [],
  71. // preprocess matching files before serving them to the browser
  72. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  73. preprocessors: {
  74. 'jspdf.js': 'coverage',
  75. 'plugins/*.js': 'coverage',
  76. 'tests/!(acroform)*/*.js': 'babel'
  77. },
  78. // web server port
  79. port: 9876,
  80. // enable / disable colors in the output (reporters and logs)
  81. colors: true,
  82. // level of logging
  83. // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
  84. logLevel: config.LOG_INFO,
  85. // enable / disable watching file and executing tests whenever any file changes
  86. autoWatch: false,
  87. // Continuous Integration mode
  88. // if true, Karma captures browsers, runs the tests and exits
  89. singleRun: false,
  90. // Concurrency level
  91. // how many browser should be started simultaneous
  92. concurrency: Infinity,
  93. browserNoActivityTimeout: 60000,
  94. captureTimeout: 120000,
  95. reporters: ['saucelabs', 'progress', 'mocha', 'coverage'], // 2
  96. browsers: Object.keys(browsers), // 3
  97. customLaunchers: browsers, // 4
  98. coverageReporter: {
  99. reporters: [
  100. {
  101. type: 'lcov',
  102. dir: 'coverage/'
  103. },
  104. {
  105. type: 'text'
  106. }
  107. ]
  108. },
  109. babelPreprocessor: {
  110. options: {
  111. presets: ['es2015'],
  112. sourceMap: 'inline'
  113. }
  114. }
  115. })
  116. }