-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
84 lines (67 loc) · 1.99 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
const babel = require("babel-core");
module.exports = function(config) {
let browsers = ["PhantomJS"];
let frameworks = ["requirejs", "jasmine"];
let reporters = ["dots", "narrow"];
let preprocessors = {
"src/**/*.js": ["babel"],
"src/**/*.jsx": ["babel"],
"src/**/*.ts": ["typescript"],
"src/**/*.tsx": ["typescript"],
"test/unit/**/*.js": ["babel"],
"test/fixtures/**/*.js": ["babel"],
"test/unit.js": ["babelexternal"]
};
let files = [
{pattern: "./bower_components/q/q.js", included: false},
{pattern: "./test/unit/**/*.spec.js", included: false},
{pattern: "./test/fixtures/**/*.js", included: false},
{pattern: "./src/**/*.ts", included: false},
{pattern: "./src/**/*.tsx", included: false},
{pattern: "./src/**/*.js", included: false},
{pattern: "./src/**/*.jsx", included: false},
"./test/unit.js"
];
function inject(content, file, done) {
content = babel.buildExternalHelpers() + "\n" + content;
done(null, content);
}
function external() {
return inject;
}
let plugins = [
"karma-jasmine",
"karma-requirejs",
"karma-babel-preprocessor",
"karma-typescript-preprocessor",
"karma-phantomjs-launcher",
"karma-chrome-launcher",
"karma-narrow-reporter",
{"preprocessor:babelexternal": ["factory", external]},
];
let options = {preprocessors, browsers, plugins, frameworks, files};
options.babelPreprocessor = {
options: {
presets: ["es2015", "react"],
plugins: ["transform-es2015-modules-amd"]
}
};
options.typescriptPreprocessor = {
options: {
sourceMap : false,
target : "ES5",
module : "amd",
noImplicitAny : false,
noResolve : true,
removeComments : true,
concatenateOutput : false
},
transformPath: function(path) {
return path.replace(/\.ts$/, ".js");
}
};
options.narrowReporter = {
showSuccess: true
};
config.set(options);
};