-
Notifications
You must be signed in to change notification settings - Fork 3
/
karma.conf.js
184 lines (171 loc) · 6.76 KB
/
karma.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
var path = require('path')
var webpack = require('karma-webpack');
var webpackConfig = require('./build/webpack.dev.js');
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
// Webpack/Karma: webpack依赖,karma不依赖 reason?
// delete webpackConfig.resolve.alias['react/lib']
// delete webpackConfig.resolve.alias['react']
// delete webpackConfig.resolve.alias['react-dom']
webpackConfig.module.loaders.push({
test: /\.json$/,
loader: 'json',
});
webpackConfig.module.noParse = [
'webim.config.js'
];
// webpackConfig.module.postLoaders = [{
// test: /\.(js|jsx)$/, exclude: /(node_modules|bower_components|tests)/,
// loader: 'istanbul-instrumenter'
// }];
// Enzyme with Karma : https://github.com/airbnb/enzyme/blob/master/docs/guides/karma.md
webpackConfig.externals = {
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true,
WebIM: 'window.WebIM'
// 'react-addons-test-utils': true,W
}
// Karma : 不支持 CommonsChunkPlugin
webpackConfig.plugins = [
new FriendlyErrorsWebpackPlugin(),
]
//TODO: use cmd to switch interface and functional test
// FILE=xxx FILE2=yyy npm run test
// console.log(process.env.FILE, process.env.FILE2)
// output: xxx yyy
// webpackConfig.devtool = 'inline-sourcemap'
webpackConfig.devtool = 'cheap-module-source-map'
module.exports = function (config) {
config.set({
// 依赖框架
frameworks: ['jasmine'],
files: [
{
pattern: './demo/javascript/dist/browser-polyfill.min.js',
included: true,
},
{
pattern: './demo/javascript/dist/webim.config.js',
included: true,
},
{
pattern: './sdk/dist/strophe-1.2.8.js',
included: true,
},
{
pattern: './demo/javascript/dist/debug.js',
included: true,
},
//
// {
// pattern: './web/styles/css/*\.css',
// included: true,
// served: false,
// },
//
// {
// pattern: './web/build/*.js',
// included: false,
// served: true,
// },
// './web/build/vendor.ui.js',
'./node_modules/phantomjs-polyfill/bind-polyfill.js',
// './demo/javascript/dist/browser-polyfill.min.js',
// './demo/javascript/dist/webim.config.js',
// './sdk/dist/strophe-1.2.8.js',
// './demo/javascript/dist/debug.js',
// './sdk/dist/websdk-1.4.10.js',
// './demo/javascript/dist/swfupload/swfupload.min.js',
// './demo/javascript/dist/demo-1.4.10.js',
'__test__/setup.js',
'__test__/interface.test.js'
],
proxies: {
"/demo/": "/base/demo/",
},
// karma support for webpack / jasmine
plugins: [
webpack,
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher',
// 'karma-coverage',
'karma-spec-reporter',
'karma-coverage-istanbul-reporter'
],
// 测试使用的浏览器 Chrome
browsers: ['Chrome'],
// browsers: ['PhantomJS'],
// 预编译操作,类似webpack的entry
preprocessors: {
'__test__/setup.js': ['webpack'],
'__test__/*.test.js': ['webpack'],
'demo/javascript/src/**/*.js': ['webpack']
},
// reporters: ['spec', 'coverage'],
// reporters: ['spec', 'coverage-istanbul'],
reporters: ['spec'],
// specReporter: {
// maxLogLines: 5, // limit number of lines logged per test
// suppressErrorSummary: true, // do not print error summary
// suppressFailed: false, // do not print information about failed tests
// suppressPassed: false, // do not print information about passed tests
// suppressSkipped: true, // do not print information about skipped tests
// showSpecTiming: false, // print the time elapsed for each spec
// failFast: false // test would finish with error when a first fail occurs.
// },
// coverageReporter: {
// dir: 'build/reports/coverage',
// reporters: [
// {type: 'html', subdir: 'report-html'},
// {type: 'lcov', subdir: 'report-lcov'},
// {type: 'cobertura', subdir: '.', file: 'cobertura.txt'}
// ],
// },
//
// coverageIstanbulReporter: {
// // reports can be any that are listed here: https://github.com/istanbuljs/istanbul-reports/tree/590e6b0089f67b723a1fdf57bc7ccc080ff189d7/lib
// reports: ['html', 'lcovonly', 'text-summary'],
//
// // base output directory. If you include %browser% in the path it will be replaced with the karma browser name
// dir: path.join(__dirname, 'coverage'),
//
// // if using webpack and pre-loaders, work around webpack breaking the source path
// fixWebpackSourcePaths: true,
//
// // stop istanbul outputting messages like `File [${filename}] ignored, nothing could be mapped`
// skipFilesWithNoCoverage: true,
//
// // Most reporters accept additional config options. You can pass these through the `report-config` option
// 'report-config': {
//
// // all options available at: https://github.com/istanbuljs/istanbul-reports/blob/590e6b0089f67b723a1fdf57bc7ccc080ff189d7/lib/html/index.js#L135-L137
// html: {
// // outputs the report in ./coverage/html
// subdir: 'html'
// }
//
// },
//
// // enforce percentage thresholds
// // anything under these percentages will cause karma to fail with an exit code of 1 if not running in watch mode
// thresholds: {
// global: { // thresholds for all files
// statements: 70,
// lines: 70,
// branches: 70,
// functions: 70
// },
// // each: { // thresholds per file
// // statements: 10,
// // lines: 10,
// // branches: 10,
// // functions: 10
// // }
// }
// },
// webpack 相关支持
webpack: webpackConfig,
webpackMiddleware: {noInfo: true, quiet: true}
});
}