-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
147 lines (142 loc) · 3.43 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
'use strict';
const path = require('path');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const nodeBuiltins = require('rollup-plugin-node-builtins');
const globals = require('rollup-plugin-node-globals');
const babel = require('rollup-plugin-babel');
const istanbul = require('rollup-plugin-istanbul');
const rollupConfig = require('./rollup.config');
let config;
const local =
typeof process.env.CI === 'undefined' || process.env.CI === 'false';
const port = process.env.SERVICE_PORT;
if (local) {
config = {
browsers: ['Chrome']
};
} else {
config = {
hostname: 'bs-local.com',
browserStack: {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
startTunnel: true,
project: 'x-autosuggest',
name: 'Automated (Karma)',
build: 'Automated (Karma)'
},
customLaunchers: {
'BS-Chrome': {
base: 'BrowserStack',
browser: 'Chrome',
os: 'Windows',
'os_version': '7',
project: 'x-autosuggest',
build: 'Automated (Karma)',
name: 'Chrome'
},
'BS-Firefox': {
base: 'BrowserStack',
browser: 'Firefox',
os: 'Windows',
'os_version': '7',
project: 'x-autosuggest',
build: 'Automated (Karma)',
name: 'Firefox'
},
'BS-IE11': {
base: 'BrowserStack',
browser: 'IE',
'browser_version': '11',
os: 'Windows',
'os_version': '7',
project: 'x-autosuggest',
build: 'Automated (Karma)',
name: 'IE11'
}
},
browsers: ['BS-Chrome', 'BS-Firefox', 'BS-IE11']
};
}
module.exports = function(baseConfig) {
baseConfig.set({
basePath: '',
frameworks: ['mocha', 'fixture'],
files: ['test/**/*.html', { pattern: 'test/index.js', watched: false }],
exclude: [],
preprocessors: {
'test/**/*.html': ['html2js'],
'test/index.js': ['rollup', 'sourcemap']
},
reporters: ['mocha', 'coverage-istanbul'],
port: port,
colors: true,
logLevel: baseConfig.LOG_INFO,
autoWatch: false,
client: {
captureConsole: true
},
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true
},
rollupPreprocessor: {
plugins: [
nodeBuiltins(),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true
}),
resolve({
preferBuiltins: true
}),
commonjs(),
babel({
include: 'node_modules/{has-flag,supports-color}/**',
runtimeHelpers: true,
babelrc: false,
configFile: path.resolve(__dirname, '.babelrc')
}),
globals(),
...rollupConfig.plugins.filter(
({ name }) => !['babel'].includes(name)
),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.svelte'],
runtimeHelpers: true
}),
babel({
include: 'node_modules/svelte/shared.js',
runtimeHelpers: true,
babelrc: false,
configFile: path.resolve(__dirname, '.babelrc')
}),
istanbul({
exclude: ['test/**/*.js', 'node_modules/**/*']
})
],
output: {
format: 'iife',
name: 'xAutosuggest',
sourcemap: baseConfig.autoWatch ? false : 'inline', // Source map support has weird behavior in watch mode
intro: 'window.TYPED_ARRAY_SUPPORT = false;' // IE9
}
},
coverageIstanbulReporter: {
dir: path.join(__dirname, 'coverage/%browser%'),
fixWebpackSourcePaths: true,
reports: ['html', 'text'],
thresholds: {
global: {
statements: 80
}
}
},
singleRun: true,
concurrency: Infinity,
...config
});
};