|
| 1 | +const webpackConfigFactory = require('../../webpack.config'); |
| 2 | + |
| 3 | +module.exports.create = function(config) { |
| 4 | + return { |
| 5 | + // base path that will be used to resolve all patterns (eg. files, exclude) |
| 6 | + basePath: '', |
| 7 | + |
| 8 | + client: { |
| 9 | + clearContext: false, |
| 10 | + spec: config.spec |
| 11 | + }, |
| 12 | + |
| 13 | + // frameworks to use |
| 14 | + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 15 | + frameworks: ['jasmine'], |
| 16 | + |
| 17 | + // list of files / patterns to load in the browser |
| 18 | + files: [ |
| 19 | + 'karma.starter.ts', |
| 20 | + ], |
| 21 | + |
| 22 | + // list of files / patterns to exclude |
| 23 | + exclude: [ ], |
| 24 | + |
| 25 | + // preprocess matching files before serving them to the browser |
| 26 | + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor |
| 27 | + preprocessors: { |
| 28 | + 'karma.starter.ts': ['webpack', 'sourcemap'], |
| 29 | + }, |
| 30 | + |
| 31 | + // test results reporter to use |
| 32 | + // possible values: 'dots', 'progress' |
| 33 | + // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 34 | + reporters: ['dots'], |
| 35 | + |
| 36 | + // web server port |
| 37 | + port: 9876, |
| 38 | + |
| 39 | + // enable / disable colors in the output (reporters and logs) |
| 40 | + colors: true, |
| 41 | + |
| 42 | + // level of logging |
| 43 | + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG |
| 44 | + logLevel: config.LOG_INFO, |
| 45 | + |
| 46 | + // enable / disable watching file and executing tests whenever any file changes |
| 47 | + autoWatch: false, |
| 48 | + |
| 49 | + // start these browsers |
| 50 | + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher |
| 51 | + browsers: ['ChromeHeadless', 'FirefoxHeadless'], |
| 52 | + |
| 53 | + // Continuous Integration mode |
| 54 | + // if true, Karma captures browsers, runs the tests and exits |
| 55 | + singleRun: true, |
| 56 | + |
| 57 | + // Concurrency level |
| 58 | + // how many browser should be started simultaneous |
| 59 | + concurrency: Infinity, |
| 60 | + |
| 61 | + // Extending timeout fixes https://github.com/handsontable/hyperformula/issues/1430 |
| 62 | + browserDisconnectTimeout : 60000, |
| 63 | + |
| 64 | + // Webpack's configuration for Karma |
| 65 | + webpack: (function() { |
| 66 | + // Take the second config from an array - full HF build. |
| 67 | + const config = webpackConfigFactory('development')[1]; |
| 68 | + |
| 69 | + // Loaders are executed from bottom to top. Push ts-loader as a first loader. |
| 70 | + config.module.rules[0].use.push({ |
| 71 | + loader: 'ts-loader', |
| 72 | + options: { |
| 73 | + configFile: 'tsconfig.test.json' |
| 74 | + } |
| 75 | + }); |
| 76 | + |
| 77 | + return config; |
| 78 | + }()), |
| 79 | + }; |
| 80 | +}; |
0 commit comments