karma.conf.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* eslint-env node */
  6. 'use strict';
  7. const path = require( 'path' );
  8. const webpack = require( 'webpack' );
  9. module.exports = function( config ) {
  10. config.set( {
  11. // base path that will be used to resolve all patterns (eg. files, exclude)
  12. basePath: '',
  13. // frameworks to use. Available frameworks: https://npmjs.org/browse/keyword/karma-adapter
  14. frameworks: [ 'mocha', 'chai', 'sinon' ],
  15. // list of files / patterns to load in the browser
  16. files: [
  17. 'tests/**/*.js'
  18. ],
  19. // list of files to exclude
  20. exclude: [
  21. 'tests/**/@(_utils|_assets)/**'
  22. ],
  23. // preprocess matching files before serving them to the browser
  24. // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
  25. preprocessors: {
  26. 'tests/**/*.js': [ 'webpack', 'sourcemap' ],
  27. 'src/**/*.js': [ 'webpack', 'sourcemap' ]
  28. },
  29. webpack: {
  30. resolve: {
  31. modules: [
  32. path.join( __dirname, 'src' ),
  33. 'node_modules'
  34. ]
  35. },
  36. module: {
  37. loaders: [
  38. {
  39. test: /\.js$/,
  40. exclude: /(node_modules\/((?!ckeditor)[a-z-]+))/,
  41. loader: 'babel-loader',
  42. enforce: 'pre',
  43. query: {
  44. plugins: [
  45. 'transform-es2015-modules-commonjs',
  46. [
  47. 'istanbul',
  48. { 'exclude': [ 'tests/**/*.js', 'node_modules/**' ] }
  49. ]
  50. ]
  51. }
  52. }
  53. ]
  54. },
  55. plugins: [
  56. new webpack.DefinePlugin( {
  57. VERSION: JSON.stringify( require( './package.json' ).version )
  58. } )
  59. ],
  60. devtool: 'inline-source-map'
  61. },
  62. webpackMiddleware: {
  63. noInfo: true,
  64. stats: 'errors-only'
  65. },
  66. // test results reporter to use
  67. // possible values: 'dots', 'progress'
  68. // available reporters: https://npmjs.org/browse/keyword/karma-reporter
  69. reporters: [ 'mocha', 'coverage' ],
  70. coverageReporter: {
  71. dir: 'coverage/',
  72. reporters: [
  73. { type: 'html', subdir: 'report-html' },
  74. { type: 'lcov', subdir: 'report-lcov' },
  75. { type: 'text', subdir: '.', file: 'text.txt' }
  76. ]
  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: true,
  87. // start these browsers
  88. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
  89. browsers: [ 'Chrome' ],
  90. // Continuous Integration mode
  91. // if true, Karma captures browsers, runs the tests and exits
  92. singleRun: false,
  93. // Concurrency level
  94. // how many browser should be started simultaneous
  95. concurrency: Infinity
  96. } );
  97. };