karma.conf.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. process.env.CHROME_BIN = '/snap/bin/chromium';
  2. module.exports = function(config) {
  3. config.set({
  4. //root path location to resolve paths defined in files and exclude
  5. basePath: '',
  6. //files/patterns to exclude from loaded files
  7. exclude: [],
  8. //files/patterns to load in the browser
  9. files: [
  10. 'tests/*.spec.js'
  11. /*parameters*/
  12. //watched: if autoWatch is true all files that have set watched to true will be watched for changes
  13. //served: should the files be served by Karma's webserver?
  14. //included: should the files be included in the browser using <script> tag?
  15. //nocache: should the files be served from disk on each request by Karma's webserver?
  16. /*assets*/
  17. //{pattern: '*.html', watched:true, served:true, included:false}
  18. //{pattern: 'images/*', watched:false, served:true, included:false}
  19. ],
  20. //executes the tests whenever one of watched files changes
  21. autoWatch: false,
  22. //if true, Karma will run tests and then exit browser
  23. singleRun: true,
  24. //if true, Karma fails on running empty test-suites
  25. failOnEmptyTestSuite:false,
  26. //reduce the kind of information passed to the bash
  27. logLevel: config.LOG_WARN, //config.LOG_DISABLE, config.LOG_ERROR, config.LOG_INFO, config.LOG_DEBUG
  28. //list of frameworks you want to use, only jasmine is installed automatically
  29. frameworks: ['jasmine'],
  30. //list of browsers to launch and capture
  31. browsers: ['ChromeHeadless'/*,'PhantomJS','Firefox','Edge','ChromeCanary','Opera','IE','Safari'*/],
  32. //list of reporters to use
  33. reporters: ['mocha' /*,'kjhtml','dots','progress','spec'*/],
  34. //address that the server will listen on, '0.0.0.0' is default
  35. listenAddress: '0.0.0.0',
  36. //hostname to be used when capturing browsers, 'localhost' is default
  37. hostname: 'localhost',
  38. //the port where the web server will be listening, 9876 is default
  39. port: 9876,
  40. //when a browser crashes, karma will try to relaunch, 2 is default
  41. retryLimit:0,
  42. //how long does Karma wait for a browser to reconnect, 2000 is default
  43. browserDisconnectTimeout: 5000,
  44. //how long will Karma wait for a message from a browser before disconnecting from it, 10000 is default
  45. browserNoActivityTimeout: 60000,
  46. //timeout for capturing a browser, 60000 is default
  47. captureTimeout: 60000,
  48. client: {
  49. //capture all console output and pipe it to the terminal, true is default
  50. captureConsole:false,
  51. //if true, Karma clears the context window upon the completion of running the tests, true is default
  52. clearContext:false,
  53. //run the tests on the same window as the client, without using iframe or a new window, false is default
  54. runInParent: false,
  55. //true: runs the tests inside an iFrame; false: runs the tests in a new window, true is default
  56. useIframe:true,
  57. jasmine:{
  58. //tells jasmine to run specs in semi random order, false is default
  59. random: false
  60. }
  61. },
  62. /*karma-webpack config*/
  63. //pass your webpack configuration for karma
  64. webpack: {
  65. node: {
  66. fs: 'empty',
  67. },
  68. module: {
  69. rules: [
  70. {
  71. test: /\.js$/,
  72. exclude: /(node_modules)/,
  73. use: {
  74. loader: "babel-loader",
  75. options: {
  76. presets: ["@babel/preset-env"]
  77. }
  78. }
  79. },
  80. {
  81. test: /\.g4$/,
  82. exclude: /(node_modules)/,
  83. use: {
  84. loader:'antlr4-webpack-loader'
  85. }
  86. }
  87. ]
  88. },
  89. },
  90. preprocessors: {
  91. //use webpack to support require() in test-suits .js files
  92. //use babel-loader from webpack to compile es2015 features in .js files
  93. //add webpack as preprocessor
  94. 'tests/*.spec.js': ['webpack']
  95. },
  96. webpackMiddleware: {
  97. //turn off webpack bash output when run the tests
  98. noInfo: true,
  99. stats: {
  100. chunks: false
  101. }
  102. },
  103. /*karma-mocha-reporter config*/
  104. mochaReporter: {
  105. output: 'full' //full, autowatch, minimal
  106. }
  107. });
  108. };