|
| 1 | +// Karma configuration |
| 2 | +// Generated on Fri Feb 17 2017 15:57:25 GMT+0800 (中国标准时间) |
| 3 | +const fileUtil = require('karma-sonarqube-unit-reporter/src/file-util.js'); |
| 4 | +const program = require('commander'); |
| 5 | +const testPath = ['./test']; |
| 6 | +const testFilePattern = 'Spec.js'; |
| 7 | +const filesForDescriptions = fileUtil.getFilesForDescriptions(testPath, testFilePattern); |
| 8 | + |
| 9 | +program.option('--single-run').option('--no-auto-watch').option('--server <server>'); |
| 10 | +const testServer = program.parse(process.argv).opts().server || 'http://localhost:8090/iserver'; |
| 11 | +console.log('testServer',testServer); |
| 12 | +module.exports = function (config) { |
| 13 | + // 设置测试的超时时间 |
| 14 | + config.set({ |
| 15 | + // base path that will be used to resolve all patterns (eg. files, exclude) |
| 16 | + basePath: '', |
| 17 | + |
| 18 | + // frameworks to use |
| 19 | + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter |
| 20 | + frameworks: ['jasmine', 'browserify'], |
| 21 | + |
| 22 | + client: { |
| 23 | + jasmine: { |
| 24 | + random: false |
| 25 | + } |
| 26 | + }, |
| 27 | + |
| 28 | + browserify: { |
| 29 | + debug: true, |
| 30 | + transform: [ |
| 31 | + [ |
| 32 | + require('babelify'), |
| 33 | + { |
| 34 | + global: true, |
| 35 | + presets: ['@babel/preset-env'], |
| 36 | + ignore: [ |
| 37 | + '../src/classic/libs/**', |
| 38 | + '../test/libs/**', |
| 39 | + '../node_modules/mapbox-gl/**', |
| 40 | + '../node_modules/three/**', |
| 41 | + '../node_modules/xlsx/**', |
| 42 | + '../node_modules/@turf/**', |
| 43 | + '../node_modules/lodash/**' |
| 44 | + ], |
| 45 | + plugins: ['istanbul', '@babel/plugin-transform-runtime'] |
| 46 | + } |
| 47 | + ], |
| 48 | + [require('browserify-css'), { global: true }], |
| 49 | + require('browserify-imgify') |
| 50 | + ] |
| 51 | + }, |
| 52 | + // list of files patterns to load in the browser |
| 53 | + // false 表示初始化的时候不会使用 script 标签直接将相关 js 引入到浏览器,需要自己写代码加载, 注意添加顺序 |
| 54 | + files: [ |
| 55 | + /***测试文件***/ |
| 56 | + './tool/**.js', |
| 57 | + './resources/**.js', |
| 58 | + './resources/img/**.png', |
| 59 | + /***classic的源码***/ |
| 60 | + /*由于除了classic其他都不依赖于8c,所以classic 的引入放在最后,以免被common覆盖*/ |
| 61 | + { pattern: '../src/classic/libs/SuperMap_Basic-8.1.1-17729.js', include: false }, |
| 62 | + { pattern: '../src/classic/libs/Lang/*.js', include: false }, |
| 63 | + { pattern: '../src/classic/theme/default/*.css', include: false }, |
| 64 | + /**测试文件**/ |
| 65 | + './test-main-classic.js', |
| 66 | + |
| 67 | + /***common的源码***/ |
| 68 | + '../src/common/**/*.js', |
| 69 | + /**测试文件**/ |
| 70 | + './test-main-common.js', |
| 71 | + |
| 72 | + /***leaflet的源码***/ |
| 73 | + { pattern: './libs/workers/TurfWorkerForTest.js', include: false }, |
| 74 | + { pattern: '../node_modules/leaflet/dist/leaflet.css', include: false }, |
| 75 | + { pattern: '../src/leaflet/**/**/*.css', include: false }, |
| 76 | + '../src/leaflet/**/!(index).js', |
| 77 | + /**测试文件**/ |
| 78 | + './test-main-leaflet.js', |
| 79 | + |
| 80 | + /***openlayers的源码***/ |
| 81 | + { pattern: '../node_modules/ol/ol.css', include: false }, |
| 82 | + { pattern: '../src/openlayers/**/**/*.css', include: false }, |
| 83 | + '../src/openlayers/**/!(index).js', |
| 84 | + /**测试文件**/ |
| 85 | + './test-main-openlayers.js', |
| 86 | + |
| 87 | + /***mapboxgl***/ |
| 88 | + { pattern: '../node_modules/mapbox-gl/dist/mapbox-gl.css', include: false }, |
| 89 | + '../src/mapboxgl/**/!(index).js', |
| 90 | + /**测试文件**/ |
| 91 | + './test-main-mapboxgl.js' |
| 92 | + ], |
| 93 | + |
| 94 | + // list of files to exclude 测试时排除的文件 |
| 95 | + exclude: [], |
| 96 | + |
| 97 | + // preprocess matching files before serving them to the browser |
| 98 | + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor |
| 99 | + preprocessors: { |
| 100 | + './tool/!(GlobeParameter).js': ['browserify'], |
| 101 | + '../node_modules/fetch-jsonp/build/fetch-jsonp.js': ['browserify'], |
| 102 | + '../src/classic/libs/SuperMap_Basic-8.1.1-17729.js': ['browserify'], |
| 103 | + '../src/classic/libs/Lang/*.js': ['browserify'], |
| 104 | + '../src/classic/**/!(index).js': ['browserify'], |
| 105 | + // './classic/**/*Spec.js': ['browserify'], |
| 106 | + './test-main-classic.js': ['browserify'], |
| 107 | + '../src/common/**/*.js': ['browserify'], |
| 108 | + // './common/**/*Spec.js': ['browserify'], |
| 109 | + './test-main-common.js': ['browserify'], |
| 110 | + |
| 111 | + '../node_modules/leaflet/dist/leaflet-src.js': ['browserify'], |
| 112 | + '../src/leaflet/**/!(index).js': ['browserify'], |
| 113 | + // './leaflet/**/*Spec.js': ['browserify'], |
| 114 | + './test-main-leaflet.js': ['browserify'], |
| 115 | + |
| 116 | + '../node_modules/ol/*.js': ['browserify'], |
| 117 | + '../node_modules/ol/**/*.js': ['browserify'], |
| 118 | + '../src/openlayers/**/!(index).js': ['browserify'], |
| 119 | + // './openlayers/**/*Spec.js': ['browserify'], |
| 120 | + './test-main-openlayers.js': ['browserify'], |
| 121 | + |
| 122 | + '../node_modules/mapbox-gl/dist/mapbox-gl-dev.js': ['browserify'], |
| 123 | + '../src/mapboxgl/**/!(index).js': ['browserify'], |
| 124 | + // './mapboxgl/**/*Spec.js': ['browserify'], |
| 125 | + './test-main-mapboxgl.js': ['browserify'] |
| 126 | + }, |
| 127 | + |
| 128 | + // test results reporter to use |
| 129 | + // possible values: 'dots', 'progress' |
| 130 | + // available reporters: https://npmjs.org/browse/keyword/karma-reporter |
| 131 | + reporters: ['progress', 'sonarqubeUnit', 'coverage', 'teamcity'], |
| 132 | + |
| 133 | + //最大超时时间 |
| 134 | + captureTimeout: 120000, |
| 135 | + browserNoActivityTimeout: 120000, |
| 136 | + browserDisconnectTimeout: 20000, |
| 137 | + |
| 138 | + coverageReporter: { |
| 139 | + dir: 'testcoverage/', |
| 140 | + reporters: [{ type: 'lcov', subdir: '.' }] |
| 141 | + }, |
| 142 | + sonarQubeUnitReporter: { |
| 143 | + sonarQubeVersion: 'LATEST', |
| 144 | + outputFile: 'testcoverage/ut_report.xml', |
| 145 | + filenameFormatter: (nextPath, result) => { |
| 146 | + return filesForDescriptions[nextPath] || ''; |
| 147 | + }, |
| 148 | + testnameFormatter: (testname, result) => { |
| 149 | + if (result.time < 1) { |
| 150 | + result.time = 1; |
| 151 | + } |
| 152 | + return testname; |
| 153 | + }, |
| 154 | + useBrowserName: false |
| 155 | + }, |
| 156 | + // web server port |
| 157 | + port: 9876, |
| 158 | + |
| 159 | + // enable / disable colors in the output (reporters and logs) |
| 160 | + colors: true, |
| 161 | + |
| 162 | + // level of logging |
| 163 | + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG |
| 164 | + logLevel: config.LOG_INFO, |
| 165 | + |
| 166 | + // enable / disable watching file and executing tests whenever any file changes |
| 167 | + autoWatch: true, |
| 168 | + |
| 169 | + // start these browsers |
| 170 | + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher |
| 171 | + browsers: ['Chrome'], |
| 172 | + |
| 173 | + // Continuous Integration mode |
| 174 | + // if true, Karma captures browsers, runs the tests and exits |
| 175 | + singleRun: false, |
| 176 | + |
| 177 | + // Concurrency level |
| 178 | + // how many browser should be started simultaneous |
| 179 | + concurrency: Infinity, |
| 180 | + proxies: { |
| 181 | + '/iserver/': testServer |
| 182 | + } |
| 183 | + }); |
| 184 | +}; |
0 commit comments