-
Notifications
You must be signed in to change notification settings - Fork 21
/
karma.conf.js
157 lines (143 loc) · 5.1 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
'use strict'
const CI_MODE = process.env.CI_MODE
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'karma-typescript'],
// list of files / patterns to load in the browser
files: [
'node_modules/whatwg-fetch/dist/fetch.umd.js',
'node_modules/fetch-mock/es5/client-bundle.js',
'node_modules/should/should.js',
{
pattern: 'test/integration/*.spec.ts',
watched: false,
},
'src/Api.ts',
],
proxies: {
//TODO Make sure to list proxies for requests to server which you can't mock here
//NOTE The path part '/base/' points to root folder of the package.
//NOTE The common case is to sent clear.cache.gif instead of image.
//'/user/avatar': '/base/mock/clear.cache.gif'
},
preprocessors: {
'**/*.ts': 'karma-typescript',
},
karmaTypescriptConfig: {
tsconfig: './tsconfig.json',
include: ['test'],
exclude: ['node_modules'],
reports: {
html: {directory: 'coverage'},
'text-summary': '',
lcovonly: '',
},
bundlerOptions: {
transforms: [require('karma-typescript-es6-transform')()],
},
},
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
reporters: ['progress', 'karma-typescript'],
port: 9876,
colors: true,
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true,
})
if (CI_MODE === 'saucelabs' && process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
const chrome = {
SL_Chrome_Latest_Mac: {
browserName: 'chrome',
browserVersion: 'latest',
platformName: 'macOS 13',
base: 'SauceLabs',
},
SL_Chrome_Previous_Mac: {
browserName: 'chrome',
browserVersion: 'latest-1',
platformName: 'macOS 12',
base: 'SauceLabs',
},
SL_Chrome_Latest_Windows: {
browserName: 'chrome',
browserVersion: 'latest',
platformName: 'Windows 11',
base: 'SauceLabs',
},
}
const firefox = {
SL_Firefox_Latest_Mac: {
browserName: 'firefox',
browserVersion: 'latest',
platformName: 'macOS 13',
base: 'SauceLabs',
},
}
const safari = {
SL_Safari_Latest_Mac: {
browserName: 'safari',
browserVersion: '16',
platformName: 'macOS 13',
base: 'SauceLabs',
},
SL_Safari_Previous_Mac: {
browserName: 'safari',
browserVersion: '15',
platformName: 'macOS 12',
base: 'SauceLabs',
},
}
const edge = {
SL_Edge_Latest: {
browserName: 'MicrosoftEdge',
browserVersion: 'latest',
platformName: 'Windows 11',
base: 'SauceLabs',
},
SL_Edge_Previous: {
browserName: 'MicrosoftEdge',
browserVersion: 'latest-1',
platformName: 'Windows 10',
base: 'SauceLabs',
},
}
// Browsers to run on Sauce Labs
const allCustomLaunchers = Object.assign({}, chrome, firefox, safari, edge)
const firstLauncher = Object.entries(allCustomLaunchers)[0]
const customLaunchers = {
[firstLauncher[0]]: firstLauncher[1]
}
// Override config for CI.
config.set({
reporters: ['progress', 'saucelabs', 'karma-typescript'],
sauceLabs: {
build: process.env.GITHUB_SHA,
connectOptions: {
connectRetries: 1,
doctor: true,
verbose: true,
},
commandTimeout: 300,
idleTimeout: 600,
maxDuration: 1800,
public: 'public',
recordScreenshots: false,
recordVideo: false,
startConnect: false,
testName: 'workfront-api',
tunnelIdentifier: 'github-action-tunnel',
},
captureTimeout: 0,
customLaunchers: customLaunchers,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: Object.keys(customLaunchers),
})
}
}