axios 1.0.0-alpha.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

Files changed (70) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +59 -48
  3. package/SECURITY.md +3 -2
  4. package/bin/ssl_hotfix.js +1 -1
  5. package/dist/axios.js +1552 -975
  6. package/dist/axios.js.map +1 -1
  7. package/dist/axios.min.js +1 -1
  8. package/dist/axios.min.js.map +1 -1
  9. package/dist/esm/axios.js +1471 -865
  10. package/dist/esm/axios.js.map +1 -1
  11. package/dist/esm/axios.min.js +1 -1
  12. package/dist/esm/axios.min.js.map +1 -1
  13. package/dist/node/axios.cjs +3750 -0
  14. package/dist/node/axios.cjs.map +1 -0
  15. package/gulpfile.js +88 -0
  16. package/index.d.ts +208 -63
  17. package/index.js +2 -1
  18. package/karma.conf.cjs +250 -0
  19. package/lib/adapters/http.js +251 -131
  20. package/lib/adapters/index.js +33 -0
  21. package/lib/adapters/xhr.js +79 -56
  22. package/lib/axios.js +33 -25
  23. package/lib/cancel/CancelToken.js +91 -88
  24. package/lib/cancel/CanceledError.js +5 -4
  25. package/lib/cancel/isCancel.js +2 -2
  26. package/lib/core/Axios.js +127 -100
  27. package/lib/core/AxiosError.js +10 -7
  28. package/lib/core/AxiosHeaders.js +274 -0
  29. package/lib/core/InterceptorManager.js +61 -53
  30. package/lib/core/buildFullPath.js +5 -4
  31. package/lib/core/dispatchRequest.js +21 -39
  32. package/lib/core/mergeConfig.js +8 -7
  33. package/lib/core/settle.js +6 -4
  34. package/lib/core/transformData.js +15 -10
  35. package/lib/defaults/index.js +46 -39
  36. package/lib/defaults/transitional.js +1 -1
  37. package/lib/env/classes/FormData.js +2 -2
  38. package/lib/env/data.js +1 -3
  39. package/lib/helpers/AxiosTransformStream.js +191 -0
  40. package/lib/helpers/AxiosURLSearchParams.js +23 -7
  41. package/lib/helpers/bind.js +2 -2
  42. package/lib/helpers/buildURL.js +16 -7
  43. package/lib/helpers/combineURLs.js +3 -2
  44. package/lib/helpers/cookies.js +43 -44
  45. package/lib/helpers/deprecatedMethod.js +4 -2
  46. package/lib/helpers/formDataToJSON.js +36 -15
  47. package/lib/helpers/fromDataURI.js +15 -13
  48. package/lib/helpers/isAbsoluteURL.js +3 -2
  49. package/lib/helpers/isAxiosError.js +4 -3
  50. package/lib/helpers/isURLSameOrigin.js +55 -56
  51. package/lib/helpers/null.js +1 -1
  52. package/lib/helpers/parseHeaders.js +24 -22
  53. package/lib/helpers/parseProtocol.js +3 -3
  54. package/lib/helpers/speedometer.js +55 -0
  55. package/lib/helpers/spread.js +3 -2
  56. package/lib/helpers/throttle.js +33 -0
  57. package/lib/helpers/toFormData.js +68 -18
  58. package/lib/helpers/toURLEncodedForm.js +5 -5
  59. package/lib/helpers/validator.js +20 -15
  60. package/lib/platform/browser/classes/FormData.js +1 -1
  61. package/lib/platform/browser/classes/URLSearchParams.js +2 -3
  62. package/lib/platform/browser/index.js +38 -6
  63. package/lib/platform/index.js +2 -2
  64. package/lib/platform/node/classes/FormData.js +2 -2
  65. package/lib/platform/node/classes/URLSearchParams.js +2 -3
  66. package/lib/platform/node/index.js +5 -4
  67. package/lib/utils.js +293 -191
  68. package/package.json +55 -22
  69. package/rollup.config.js +36 -6
  70. package/lib/helpers/normalizeHeaderName.js +0 -12
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // TypeScript Version: 4.1
2
- type AxiosHeaders = Record<string, string | string[] | number | boolean>;
2
+ type AxiosHeaderValue = string | string[] | number | boolean | null;
3
+ type RawAxiosHeaders = Record<string, AxiosHeaderValue>;
3
4
 
4
5
  type MethodsHeaders = {
5
6
  [Key in Method as Lowercase<Key>]: AxiosHeaders;
@@ -9,18 +10,78 @@ interface CommonHeaders {
9
10
  common: AxiosHeaders;
10
11
  }
11
12
 
12
- export type AxiosRequestHeaders = Partial<AxiosHeaders & MethodsHeaders & CommonHeaders>;
13
+ type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
13
14
 
14
- export type AxiosResponseHeaders = Record<string, string> & {
15
+ type AxiosHeaderSetter = (value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher) => AxiosHeaders;
16
+
17
+ type AxiosHeaderGetter = ((parser?: RegExp) => RegExpExecArray | null) |
18
+ ((matcher?: AxiosHeaderMatcher) => AxiosHeaderValue);
19
+
20
+ type AxiosHeaderTester = (matcher?: AxiosHeaderMatcher) => boolean;
21
+
22
+ export class AxiosHeaders {
23
+ constructor(
24
+ headers?: RawAxiosHeaders | AxiosHeaders,
25
+ defaultHeaders?: RawAxiosHeaders | AxiosHeaders
26
+ );
27
+
28
+ set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
29
+ set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
30
+
31
+ get(headerName: string, parser: RegExp): RegExpExecArray | null;
32
+ get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue;
33
+
34
+ has(header: string, matcher?: true | AxiosHeaderMatcher): boolean;
35
+
36
+ delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
37
+
38
+ clear(): boolean;
39
+
40
+ normalize(format: boolean): AxiosHeaders;
41
+
42
+ toJSON(): RawAxiosHeaders;
43
+
44
+ static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
45
+
46
+ static accessor(header: string | string[]): AxiosHeaders;
47
+
48
+ setContentType: AxiosHeaderSetter;
49
+ getContentType: AxiosHeaderGetter;
50
+ hasContentType: AxiosHeaderTester;
51
+
52
+ setContentLength: AxiosHeaderSetter;
53
+ getContentLength: AxiosHeaderGetter;
54
+ hasContentLength: AxiosHeaderTester;
55
+
56
+ setAccept: AxiosHeaderSetter;
57
+ getAccept: AxiosHeaderGetter;
58
+ hasAccept: AxiosHeaderTester;
59
+
60
+ setUserAgent: AxiosHeaderSetter;
61
+ getUserAgent: AxiosHeaderGetter;
62
+ hasUserAgent: AxiosHeaderTester;
63
+
64
+ setContentEncoding: AxiosHeaderSetter;
65
+ getContentEncoding: AxiosHeaderGetter;
66
+ hasContentEncoding: AxiosHeaderTester;
67
+ }
68
+
69
+ export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
70
+
71
+ export type AxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders> & AxiosHeaders;
72
+
73
+ export type RawAxiosResponseHeaders = Partial<Record<string, string> & {
15
74
  "set-cookie"?: string[]
16
- };
75
+ }>;
76
+
77
+ export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
17
78
 
18
79
  export interface AxiosRequestTransformer {
19
- (data: any, headers: AxiosRequestHeaders): any;
80
+ (this: AxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
20
81
  }
21
82
 
22
83
  export interface AxiosResponseTransformer {
23
- (data: any, headers?: AxiosResponseHeaders, status?: number): any;
84
+ (this: AxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;
24
85
  }
25
86
 
26
87
  export interface AxiosAdapter {
@@ -42,39 +103,105 @@ export interface AxiosProxyConfig {
42
103
  protocol?: string;
43
104
  }
44
105
 
106
+ export enum HttpStatusCode {
107
+ Continue = 100,
108
+ SwitchingProtocols = 101,
109
+ Processing = 102,
110
+ EarlyHints = 103,
111
+ Ok = 200,
112
+ Created = 201,
113
+ Accepted = 202,
114
+ NonAuthoritativeInformation = 203,
115
+ NoContent = 204,
116
+ ResetContent = 205,
117
+ PartialContent = 206,
118
+ MultiStatus = 207,
119
+ AlreadyReported = 208,
120
+ ImUsed = 226,
121
+ MultipleChoices = 300,
122
+ MovedPermanently = 301,
123
+ Found = 302,
124
+ SeeOther = 303,
125
+ NotModified = 304,
126
+ UseProxy = 305,
127
+ Unused = 306,
128
+ TemporaryRedirect = 307,
129
+ PermanentRedirect = 308,
130
+ BadRequest = 400,
131
+ Unauthorized = 401,
132
+ PaymentRequired = 402,
133
+ Forbidden = 403,
134
+ NotFound = 404,
135
+ MethodNotAllowed = 405,
136
+ NotAcceptable = 406,
137
+ ProxyAuthenticationRequired = 407,
138
+ RequestTimeout = 408,
139
+ Conflict = 409,
140
+ Gone = 410,
141
+ LengthRequired = 411,
142
+ PreconditionFailed = 412,
143
+ PayloadTooLarge = 413,
144
+ UriTooLong = 414,
145
+ UnsupportedMediaType = 415,
146
+ RangeNotSatisfiable = 416,
147
+ ExpectationFailed = 417,
148
+ ImATeapot = 418,
149
+ MisdirectedRequest = 421,
150
+ UnprocessableEntity = 422,
151
+ Locked = 423,
152
+ FailedDependency = 424,
153
+ TooEarly = 425,
154
+ UpgradeRequired = 426,
155
+ PreconditionRequired = 428,
156
+ TooManyRequests = 429,
157
+ RequestHeaderFieldsTooLarge = 431,
158
+ UnavailableForLegalReasons = 451,
159
+ InternalServerError = 500,
160
+ NotImplemented = 501,
161
+ BadGateway = 502,
162
+ ServiceUnavailable = 503,
163
+ GatewayTimeout = 504,
164
+ HttpVersionNotSupported = 505,
165
+ VariantAlsoNegotiates = 506,
166
+ InsufficientStorage = 507,
167
+ LoopDetected = 508,
168
+ NotExtended = 510,
169
+ NetworkAuthenticationRequired = 511,
170
+ }
171
+
45
172
  export type Method =
46
- | 'get' | 'GET'
47
- | 'delete' | 'DELETE'
48
- | 'head' | 'HEAD'
49
- | 'options' | 'OPTIONS'
50
- | 'post' | 'POST'
51
- | 'put' | 'PUT'
52
- | 'patch' | 'PATCH'
53
- | 'purge' | 'PURGE'
54
- | 'link' | 'LINK'
55
- | 'unlink' | 'UNLINK';
173
+ | 'get' | 'GET'
174
+ | 'delete' | 'DELETE'
175
+ | 'head' | 'HEAD'
176
+ | 'options' | 'OPTIONS'
177
+ | 'post' | 'POST'
178
+ | 'put' | 'PUT'
179
+ | 'patch' | 'PATCH'
180
+ | 'purge' | 'PURGE'
181
+ | 'link' | 'LINK'
182
+ | 'unlink' | 'UNLINK';
56
183
 
57
184
  export type ResponseType =
58
- | 'arraybuffer'
59
- | 'blob'
60
- | 'document'
61
- | 'json'
62
- | 'text'
63
- | 'stream';
64
-
65
- export type responseEncoding =
66
- | 'ascii' | 'ASCII'
67
- | 'ansi' | 'ANSI'
68
- | 'binary' | 'BINARY'
69
- | 'base64' | 'BASE64'
70
- | 'base64url' | 'BASE64URL'
71
- | 'hex' | 'HEX'
72
- | 'latin1' | 'LATIN1'
73
- | 'ucs-2' | 'UCS-2'
74
- | 'ucs2' | 'UCS2'
75
- | 'utf-8' | 'UTF-8'
76
- | 'utf8' | 'UTF8'
77
- | 'utf16le' | 'UTF16LE';
185
+ | 'arraybuffer'
186
+ | 'blob'
187
+ | 'document'
188
+ | 'json'
189
+ | 'text'
190
+ | 'stream';
191
+
192
+ export type responseEncoding =
193
+ | 'ascii' | 'ASCII'
194
+ | 'ansi' | 'ANSI'
195
+ | 'binary' | 'BINARY'
196
+ | 'base64' | 'BASE64'
197
+ | 'base64url' | 'BASE64URL'
198
+ | 'hex' | 'HEX'
199
+ | 'latin1' | 'LATIN1'
200
+ | 'ucs-2' | 'UCS-2'
201
+ | 'ucs2' | 'UCS2'
202
+ | 'utf-8' | 'UTF-8'
203
+ | 'utf8' | 'UTF8'
204
+ | 'utf16le' | 'UTF16LE';
78
205
 
79
206
  export interface TransitionalOptions {
80
207
  silentJSONParsing?: boolean;
@@ -109,7 +236,7 @@ export interface SerializerOptions {
109
236
  visitor?: SerializerVisitor;
110
237
  dots?: boolean;
111
238
  metaTokens?: boolean;
112
- indexes?: boolean;
239
+ indexes?: boolean | null;
113
240
  }
114
241
 
115
242
  // tslint:disable-next-line
@@ -124,17 +251,34 @@ export interface ParamsSerializerOptions extends SerializerOptions {
124
251
  encode?: ParamEncoder;
125
252
  }
126
253
 
254
+ type MaxUploadRate = number;
255
+
256
+ type MaxDownloadRate = number;
257
+
258
+ export interface AxiosProgressEvent {
259
+ loaded: number;
260
+ total?: number;
261
+ progress?: number;
262
+ bytes: number;
263
+ rate?: number;
264
+ estimated?: number;
265
+ upload?: boolean;
266
+ download?: boolean;
267
+ }
268
+
269
+ type Milliseconds = number;
270
+
127
271
  export interface AxiosRequestConfig<D = any> {
128
272
  url?: string;
129
273
  method?: Method | string;
130
274
  baseURL?: string;
131
275
  transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
132
276
  transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
133
- headers?: AxiosRequestHeaders;
277
+ headers?: RawAxiosRequestHeaders;
134
278
  params?: any;
135
279
  paramsSerializer?: ParamsSerializerOptions;
136
280
  data?: D;
137
- timeout?: number;
281
+ timeout?: Milliseconds;
138
282
  timeoutErrorMessage?: string;
139
283
  withCredentials?: boolean;
140
284
  adapter?: AxiosAdapter;
@@ -143,12 +287,13 @@ export interface AxiosRequestConfig<D = any> {
143
287
  responseEncoding?: responseEncoding | string;
144
288
  xsrfCookieName?: string;
145
289
  xsrfHeaderName?: string;
146
- onUploadProgress?: (progressEvent: ProgressEvent) => void;
147
- onDownloadProgress?: (progressEvent: ProgressEvent) => void;
290
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
291
+ onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
148
292
  maxContentLength?: number;
149
293
  validateStatus?: ((status: number) => boolean) | null;
150
294
  maxBodyLength?: number;
151
295
  maxRedirects?: number;
296
+ maxRate?: number | [MaxUploadRate, MaxDownloadRate];
152
297
  beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
153
298
  socketPath?: string | null;
154
299
  httpAgent?: any;
@@ -166,17 +311,17 @@ export interface AxiosRequestConfig<D = any> {
166
311
  }
167
312
 
168
313
  export interface HeadersDefaults {
169
- common: AxiosRequestHeaders;
170
- delete: AxiosRequestHeaders;
171
- get: AxiosRequestHeaders;
172
- head: AxiosRequestHeaders;
173
- post: AxiosRequestHeaders;
174
- put: AxiosRequestHeaders;
175
- patch: AxiosRequestHeaders;
176
- options?: AxiosRequestHeaders;
177
- purge?: AxiosRequestHeaders;
178
- link?: AxiosRequestHeaders;
179
- unlink?: AxiosRequestHeaders;
314
+ common: RawAxiosRequestHeaders;
315
+ delete: RawAxiosRequestHeaders;
316
+ get: RawAxiosRequestHeaders;
317
+ head: RawAxiosRequestHeaders;
318
+ post: RawAxiosRequestHeaders;
319
+ put: RawAxiosRequestHeaders;
320
+ patch: RawAxiosRequestHeaders;
321
+ options?: RawAxiosRequestHeaders;
322
+ purge?: RawAxiosRequestHeaders;
323
+ link?: RawAxiosRequestHeaders;
324
+ unlink?: RawAxiosRequestHeaders;
180
325
  }
181
326
 
182
327
  export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
@@ -184,25 +329,25 @@ export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'hea
184
329
  }
185
330
 
186
331
  export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
187
- headers?: AxiosRequestHeaders | Partial<HeadersDefaults>;
332
+ headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
188
333
  }
189
334
 
190
335
  export interface AxiosResponse<T = any, D = any> {
191
336
  data: T;
192
337
  status: number;
193
338
  statusText: string;
194
- headers: AxiosResponseHeaders;
339
+ headers: RawAxiosResponseHeaders | AxiosResponseHeaders;
195
340
  config: AxiosRequestConfig<D>;
196
341
  request?: any;
197
342
  }
198
343
 
199
344
  export class AxiosError<T = unknown, D = any> extends Error {
200
345
  constructor(
201
- message?: string,
202
- code?: string,
203
- config?: AxiosRequestConfig<D>,
204
- request?: any,
205
- response?: AxiosResponse<T, D>
346
+ message?: string,
347
+ code?: string,
348
+ config?: AxiosRequestConfig<D>,
349
+ request?: any,
350
+ response?: AxiosResponse<T, D>
206
351
  );
207
352
 
208
353
  config?: AxiosRequestConfig<D>;
@@ -266,7 +411,7 @@ export interface AxiosInterceptorOptions {
266
411
  }
267
412
 
268
413
  export interface AxiosInterceptorManager<V> {
269
- use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
414
+ use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;
270
415
  eject(id: number): void;
271
416
  }
272
417
 
@@ -292,12 +437,12 @@ export class Axios {
292
437
  }
293
438
 
294
439
  export interface AxiosInstance extends Axios {
295
- <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): AxiosPromise<R>;
296
- <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): AxiosPromise<R>;
440
+ <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
441
+ <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
297
442
 
298
443
  defaults: Omit<AxiosDefaults, 'headers'> & {
299
444
  headers: HeadersDefaults & {
300
- [key: string]: string | number | boolean | undefined
445
+ [key: string]: AxiosHeaderValue
301
446
  }
302
447
  };
303
448
  }
package/index.js CHANGED
@@ -1 +1,2 @@
1
- module.exports = require('./lib/axios');
1
+ import axios from './lib/axios.js';
2
+ export default axios;
package/karma.conf.cjs ADDED
@@ -0,0 +1,250 @@
1
+ /* eslint-disable no-console */
2
+ /* eslint-disable no-unused-vars */
3
+ /* eslint-disable func-names */
4
+ // Karma configuration
5
+ // Generated on Fri Aug 15 2014 23:11:13 GMT-0500 (CDT)
6
+
7
+ 'use strict';
8
+
9
+ var resolve = require('@rollup/plugin-node-resolve').default;
10
+ var commonjs = require('@rollup/plugin-commonjs');
11
+
12
+ function createCustomLauncher(browser, version, platform) {
13
+ return {
14
+ base: 'SauceLabs',
15
+ browserName: browser,
16
+ version: version,
17
+ platform: platform
18
+ };
19
+ }
20
+
21
+ module.exports = function(config) {
22
+ var customLaunchers = {};
23
+ var browsers = process.env.Browsers && process.env.Browsers.split(',');
24
+ var sauceLabs;
25
+
26
+ if (process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY) {
27
+ customLaunchers = {};
28
+
29
+ var runAll = true;
30
+ var options = [
31
+ 'SAUCE_CHROME',
32
+ 'SAUCE_FIREFOX',
33
+ 'SAUCE_SAFARI',
34
+ 'SAUCE_OPERA',
35
+ 'SAUCE_IE',
36
+ 'SAUCE_EDGE',
37
+ 'SAUCE_IOS',
38
+ 'SAUCE_ANDROID'
39
+ ];
40
+
41
+ options.forEach(function(opt) {
42
+ if (process.env[opt]) {
43
+ runAll = false;
44
+ }
45
+ });
46
+
47
+ // Chrome
48
+ if (runAll || process.env.SAUCE_CHROME) {
49
+ customLaunchers.SL_Chrome = createCustomLauncher('chrome');
50
+ // customLaunchers.SL_ChromeDev = createCustomLauncher('chrome', 'dev');
51
+ // customLaunchers.SL_ChromeBeta = createCustomLauncher('chrome', 'beta');
52
+ }
53
+
54
+ // Firefox
55
+ if (runAll || process.env.SAUCE_FIREFOX) {
56
+ //customLaunchers.SL_Firefox = createCustomLauncher('firefox');
57
+ // customLaunchers.SL_FirefoxDev = createCustomLauncher('firefox', 'dev');
58
+ // customLaunchers.SL_FirefoxBeta = createCustomLauncher('firefox', 'beta');
59
+ }
60
+
61
+ // Safari
62
+ if (runAll || process.env.SAUCE_SAFARI) {
63
+ // customLaunchers.SL_Safari7 = createCustomLauncher('safari', 7);
64
+ // customLaunchers.SL_Safari8 = createCustomLauncher('safari', 8);
65
+ customLaunchers.SL_Safari9 = createCustomLauncher(
66
+ 'safari',
67
+ 9.0,
68
+ 'OS X 10.11'
69
+ );
70
+ customLaunchers.SL_Safari10 = createCustomLauncher(
71
+ 'safari',
72
+ '10.1',
73
+ 'macOS 10.12'
74
+ );
75
+ customLaunchers.SL_Safari11 = createCustomLauncher(
76
+ 'safari',
77
+ '11.1',
78
+ 'macOS 10.13'
79
+ );
80
+ }
81
+
82
+ // Opera
83
+ if (runAll || process.env.SAUCE_OPERA) {
84
+ // TODO The available versions of Opera are too old and lack basic APIs
85
+ // customLaunchers.SL_Opera11 = createCustomLauncher('opera', 11, 'Windows XP');
86
+ // customLaunchers.SL_Opera12 = createCustomLauncher('opera', 12, 'Windows 7');
87
+ }
88
+
89
+ // IE
90
+ if (runAll || process.env.SAUCE_IE) {
91
+ customLaunchers.SL_IE11 = createCustomLauncher('internet explorer', 11, 'Windows 8.1');
92
+ }
93
+
94
+ // Edge
95
+ if (runAll || process.env.SAUCE_EDGE) {
96
+ customLaunchers.SL_Edge = createCustomLauncher('microsoftedge', null, 'Windows 10');
97
+ }
98
+
99
+ // IOS
100
+ if (runAll || process.env.SAUCE_IOS) {
101
+ // TODO IOS7 capture always timesout
102
+ // customLaunchers.SL_IOS7 = createCustomLauncher('iphone', '7.1', 'OS X 10.10');
103
+ // TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
104
+ // customLaunchers.SL_IOS8 = createCustomLauncher('iphone', '8.4', 'OS X 10.10');
105
+ // customLaunchers.SL_IOS9 = createCustomLauncher('iphone', '9.2', 'OS X 10.10');
106
+ }
107
+
108
+ // Android
109
+ if (runAll || process.env.SAUCE_ANDROID) {
110
+ // TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
111
+ // customLaunchers.SL_Android4 = createCustomLauncher('android', '4.4', 'Linux');
112
+ // customLaunchers.SL_Android5 = createCustomLauncher('android', '5.1', 'Linux');
113
+ }
114
+
115
+ browsers = Object.keys(customLaunchers);
116
+
117
+ sauceLabs = {
118
+ recordScreenshots: false,
119
+ connectOptions: {
120
+ // port: 5757,
121
+ logfile: 'sauce_connect.log'
122
+ },
123
+ public: 'public'
124
+ };
125
+ } else if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
126
+ console.log(
127
+ 'Cannot run on Sauce Labs as encrypted environment variables are not available to PRs. ' +
128
+ 'Running on Travis.'
129
+ );
130
+ browsers = ['Firefox'];
131
+ } else if (process.env.GITHUB_ACTIONS === 'true') {
132
+ console.log('Running ci on Github Actions.');
133
+ browsers = ['FirefoxHeadless', 'ChromeHeadless'];
134
+ } else {
135
+ browsers = browsers || ['Chrome'];
136
+ console.log(`Running ${browsers} locally since SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are not set.`);
137
+ }
138
+
139
+ config.set({
140
+ // base path that will be used to resolve all patterns (eg. files, exclude)
141
+ basePath: '',
142
+
143
+
144
+ // frameworks to use
145
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
146
+ frameworks: ['jasmine-ajax', 'jasmine', 'sinon'],
147
+
148
+
149
+ // list of files / patterns to load in the browser
150
+ files: [
151
+ {pattern: 'test/specs/__helpers.js', watched: false},
152
+ {pattern: 'test/specs/**/*.spec.js', watched: false}
153
+ ],
154
+
155
+
156
+ // list of files to exclude
157
+ exclude: [],
158
+
159
+
160
+ // preprocess matching files before serving them to the browser
161
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
162
+ preprocessors: {
163
+ 'test/specs/__helpers.js': ['rollup'],
164
+ 'test/specs/**/*.spec.js': ['rollup']
165
+ },
166
+
167
+ rollupPreprocessor: {
168
+ plugins: [
169
+ resolve({browser: true}),
170
+ commonjs()
171
+ ],
172
+ output: {
173
+ format: 'iife',
174
+ name: '_axios',
175
+ sourcemap: 'inline'
176
+ }
177
+ },
178
+
179
+
180
+ // test results reporter to use
181
+ // possible values: 'dots', 'progress'
182
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
183
+ // Disable code coverage, as it's breaking CI:
184
+ // reporters: ['dots', 'coverage', 'saucelabs'],
185
+ reporters: ['progress'],
186
+
187
+
188
+ // web server port
189
+ port: 9876,
190
+
191
+
192
+ // Increase timeouts to prevent the issue with disconnected tests (https://goo.gl/nstA69)
193
+ captureTimeout: 4 * 60 * 1000,
194
+ browserDisconnectTimeout: 10000,
195
+ browserDisconnectTolerance: 1,
196
+ browserNoActivityTimeout: 4 * 60 * 1000,
197
+
198
+
199
+ // enable / disable colors in the output (reporters and logs)
200
+ colors: true,
201
+
202
+
203
+ // level of logging
204
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
205
+ logLevel: config.LOG_INFO,
206
+
207
+
208
+ // enable / disable watching file and executing tests whenever any file changes
209
+ autoWatch: false,
210
+
211
+
212
+ // start these browsers
213
+ // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
214
+ browsers: browsers,
215
+
216
+
217
+ // Continuous Integration mode
218
+ // if true, Karma captures browsers, runs the tests and exits
219
+ singleRun: false,
220
+
221
+ // Webpack config
222
+ webpack: {
223
+ mode: 'development',
224
+ cache: true,
225
+ devtool: 'inline-source-map',
226
+ externals: [
227
+ {
228
+ './adapters/http': 'var undefined'
229
+ }
230
+ ]
231
+ },
232
+
233
+ webpackServer: {
234
+ stats: {
235
+ colors: true
236
+ }
237
+ },
238
+
239
+
240
+ // Coverage reporting
241
+ coverageReporter: {
242
+ type: 'lcov',
243
+ dir: 'coverage/',
244
+ subdir: '.'
245
+ },
246
+
247
+ sauceLabs: sauceLabs,
248
+ customLaunchers: customLaunchers
249
+ });
250
+ };