forked from beauby/jsonapi-datastore
/
karma.conf.js
142 lines (136 loc) · 3.42 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
'use strict';
const path = require('path');
const fs = require('fs');
const { default: 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 { default: babel } = require('@rollup/plugin-babel');
const istanbul = require('rollup-plugin-istanbul');
const rollupConfig = require('./rollup.config');
let config;
const isCI =
typeof process.env.CI !== 'undefined' && process.env.CI !== 'false';
const isPR =
typeof process.env.TRAVIS_PULL_REQUEST !== 'undefined' &&
process.env.TRAVIS_PULL_REQUEST !== 'false';
const local = !isCI || (isCI && isPR);
const port = 0;
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: 'jsonapi-data-manager',
name: 'Automated (Karma)',
build: 'Automated (Karma)'
},
customLaunchers: {
'BS-Chrome': {
base: 'BrowserStack',
browser: 'Chrome',
os: 'Windows',
'os_version': '7',
project: 'jsonapi-data-manager',
build: 'Automated (Karma)',
name: 'Chrome'
},
'BS-Firefox': {
base: 'BrowserStack',
browser: 'Firefox',
os: 'Windows',
'os_version': '7',
project: 'jsonapi-data-manager',
build: 'Automated (Karma)',
name: 'Firefox'
},
'BS-IE11': {
base: 'BrowserStack',
browser: 'IE',
'browser_version': '11',
os: 'Windows',
'os_version': '7',
project: 'jsonapi-data-manager',
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/**/*.js', watched: false }],
exclude: [],
preprocessors: {
'test/**/*.html': ['html2js'],
'test/**/*.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/**',
babelHelpers: 'runtime'
}),
resolve({
preferBuiltins: true
}),
commonjs(),
babel({
include: 'node_modules/{has-flag,supports-color}/**',
babelHelpers: 'runtime',
babelrc: false,
configFile: path.resolve(__dirname, '.babelrc')
}),
globals(),
...rollupConfig.plugins.filter(
({ name }) => !['babel'].includes(name)
),
istanbul({
exclude: ['test/**/*.js', 'node_modules/**/*']
})
],
output: {
format: 'iife',
name: 'jsonapiDataManager',
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: JSON.parse(
fs.readFileSync(path.join(__dirname, '.nycrc'), 'utf8')
)
}
},
singleRun: true,
concurrency: Infinity,
...config
});
};