@percy/sdk-utils 1.0.0-beta.70 → 1.0.0-beta.74
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.
- package/dist/bundle.js +66 -38
- package/dist/percy-dom.js +6 -2
- package/dist/percy-enabled.js +17 -6
- package/dist/post-snapshot.js +6 -2
- package/dist/request.js +6 -2
- package/package.json +11 -11
- package/test/client.js +34 -21
- package/test/server.js +2 -1
package/dist/bundle.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function() {
|
|
2
|
-
(function (exports, require$$0$1
|
|
2
|
+
(function (exports, require$$0$1) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
const process = (typeof globalThis !== "undefined" && globalThis.process) || {};
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
11
11
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
12
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
13
12
|
|
|
14
13
|
function getAugmentedNamespace(n) {
|
|
15
14
|
if (n.__esModule) return n;
|
|
@@ -34,10 +33,11 @@
|
|
|
34
33
|
const ANSI_REG = new RegExp('[\\u001B\\u009B][[\\]()#;?]*((?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' + '|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))', 'g'); // color names by ansi escape code
|
|
35
34
|
|
|
36
35
|
const ANSI_COLORS = {
|
|
37
|
-
'
|
|
38
|
-
'
|
|
36
|
+
'91m': 'red',
|
|
37
|
+
'32m': 'green',
|
|
38
|
+
'93m': 'yellow',
|
|
39
39
|
'34m': 'blue',
|
|
40
|
-
'
|
|
40
|
+
'95m': 'magenta',
|
|
41
41
|
'90m': 'grey'
|
|
42
42
|
}; // colorize each line of a string using an ansi escape sequence
|
|
43
43
|
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
} // map ansi colors to bound colorize functions
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
const colors = entries(ANSI_COLORS).reduce((colors,
|
|
51
|
+
const colors = entries(ANSI_COLORS).reduce((colors, _ref) => {
|
|
52
|
+
let [code, name] = _ref;
|
|
52
53
|
return assign(colors, {
|
|
53
54
|
[name]: colorize.bind(null, code)
|
|
54
55
|
});
|
|
@@ -113,8 +114,8 @@
|
|
|
113
114
|
|
|
114
115
|
|
|
115
116
|
loglevel(level) {
|
|
116
|
-
if (
|
|
117
|
-
this.level
|
|
117
|
+
if (level) this.level = level;
|
|
118
|
+
return this.level;
|
|
118
119
|
} // Change namespaces by generating an array of namespace regular expressions from a
|
|
119
120
|
// comma separated debug string
|
|
120
121
|
|
|
@@ -147,9 +148,13 @@
|
|
|
147
148
|
return Object.keys(LOG_LEVELS).reduce((group, level) => Object.assign(group, {
|
|
148
149
|
[level]: this.log.bind(this, name, level)
|
|
149
150
|
}), {
|
|
150
|
-
progress: this.progress.bind(this, name),
|
|
151
151
|
deprecated: this.deprecated.bind(this, name),
|
|
152
|
-
shouldLog: this.shouldLog.bind(this, name)
|
|
152
|
+
shouldLog: this.shouldLog.bind(this, name),
|
|
153
|
+
progress: this.progress.bind(this, name),
|
|
154
|
+
format: this.format.bind(this, name),
|
|
155
|
+
loglevel: this.loglevel.bind(this),
|
|
156
|
+
stdout: this.constructor.stdout,
|
|
157
|
+
stderr: this.constructor.stderr
|
|
153
158
|
});
|
|
154
159
|
} // Query for a set of logs by filtering the in-memory store
|
|
155
160
|
|
|
@@ -159,10 +164,18 @@
|
|
|
159
164
|
} // Formats messages before they are logged to stdio
|
|
160
165
|
|
|
161
166
|
|
|
162
|
-
format(
|
|
167
|
+
format(debug, level, message, elapsed) {
|
|
163
168
|
let label = 'percy';
|
|
164
169
|
let suffix = '';
|
|
165
170
|
|
|
171
|
+
if (arguments.length === 1) {
|
|
172
|
+
// format(message)
|
|
173
|
+
[debug, message] = [null, debug];
|
|
174
|
+
} else if (arguments.length === 2) {
|
|
175
|
+
// format(debug, message)
|
|
176
|
+
[level, message] = [null, level];
|
|
177
|
+
}
|
|
178
|
+
|
|
166
179
|
if (this.level === 'debug') {
|
|
167
180
|
// include debug info in the label
|
|
168
181
|
if (debug) label += `:${debug}`; // include elapsed time since last log
|
|
@@ -196,7 +209,7 @@
|
|
|
196
209
|
} = this.constructor;
|
|
197
210
|
|
|
198
211
|
if (stdout.isTTY || !this._progress) {
|
|
199
|
-
message && (message = this.format(
|
|
212
|
+
message && (message = this.format(debug, message));
|
|
200
213
|
if (stdout.isTTY) stdout.cursorTo(0);else message && (message = message + '\n');
|
|
201
214
|
if (message) stdout.write(message);
|
|
202
215
|
if (stdout.isTTY) stdout.clearLine(1);
|
|
@@ -229,7 +242,8 @@
|
|
|
229
242
|
// information to store with the message and other info
|
|
230
243
|
|
|
231
244
|
|
|
232
|
-
log(debug, level, message
|
|
245
|
+
log(debug, level, message) {
|
|
246
|
+
let meta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
233
247
|
// message might be an error object
|
|
234
248
|
let isError = typeof message !== 'string' && (level === 'error' || level === 'debug');
|
|
235
249
|
let error = isError && message; // if remote, send logs there
|
|
@@ -264,7 +278,7 @@
|
|
|
264
278
|
if (this.shouldLog(debug, level)) {
|
|
265
279
|
let elapsed = timestamp - (this.lastlog || timestamp);
|
|
266
280
|
if (isError && this.level !== 'debug') message = error.toString();
|
|
267
|
-
this.write(level, this.format(
|
|
281
|
+
this.write(level, this.format(debug, error ? 'error' : level, message, elapsed));
|
|
268
282
|
this.lastlog = timestamp;
|
|
269
283
|
}
|
|
270
284
|
} // Writes a message to stdio based on the loglevel
|
|
@@ -300,9 +314,10 @@
|
|
|
300
314
|
}
|
|
301
315
|
})); // attach remote logging handler
|
|
302
316
|
|
|
303
|
-
socket.onmessage =
|
|
304
|
-
|
|
305
|
-
|
|
317
|
+
socket.onmessage = _ref => {
|
|
318
|
+
let {
|
|
319
|
+
data
|
|
320
|
+
} = _ref;
|
|
306
321
|
let {
|
|
307
322
|
log,
|
|
308
323
|
logAll
|
|
@@ -318,7 +333,8 @@
|
|
|
318
333
|
} // Connects to a remote logger
|
|
319
334
|
|
|
320
335
|
|
|
321
|
-
async remote(createSocket
|
|
336
|
+
async remote(createSocket) {
|
|
337
|
+
let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
322
338
|
if (this.isRemote) return; // if not already connected, wait until the timeout
|
|
323
339
|
|
|
324
340
|
let err = await new Promise(resolve => {
|
|
@@ -360,9 +376,10 @@
|
|
|
360
376
|
} // attach an incoming message handler
|
|
361
377
|
|
|
362
378
|
|
|
363
|
-
this.socket.onmessage =
|
|
364
|
-
|
|
365
|
-
|
|
379
|
+
this.socket.onmessage = _ref2 => {
|
|
380
|
+
let {
|
|
381
|
+
data
|
|
382
|
+
} = _ref2;
|
|
366
383
|
let {
|
|
367
384
|
env
|
|
368
385
|
} = JSON.parse(data); // update local environment info
|
|
@@ -385,10 +402,11 @@
|
|
|
385
402
|
|
|
386
403
|
var logger$1 = /*#__PURE__*/Object.freeze({
|
|
387
404
|
__proto__: null,
|
|
405
|
+
PercyLogger: PercyLogger,
|
|
388
406
|
'default': PercyLogger
|
|
389
407
|
});
|
|
390
408
|
|
|
391
|
-
class
|
|
409
|
+
class PercyBrowserLogger extends PercyLogger {
|
|
392
410
|
write(level, message) {
|
|
393
411
|
let out = ['warn', 'error'].includes(level) ? level : 'log';
|
|
394
412
|
let colors = [];
|
|
@@ -407,7 +425,8 @@
|
|
|
407
425
|
|
|
408
426
|
var browser = /*#__PURE__*/Object.freeze({
|
|
409
427
|
__proto__: null,
|
|
410
|
-
|
|
428
|
+
PercyBrowserLogger: PercyBrowserLogger,
|
|
429
|
+
'default': PercyBrowserLogger
|
|
411
430
|
});
|
|
412
431
|
|
|
413
432
|
var require$$0 = /*@__PURE__*/getAugmentedNamespace(browser);
|
|
@@ -423,16 +442,21 @@
|
|
|
423
442
|
}
|
|
424
443
|
|
|
425
444
|
Object.assign(logger, {
|
|
426
|
-
format: (
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return new Logger().
|
|
445
|
+
format: function () {
|
|
446
|
+
return new Logger().format(...arguments);
|
|
447
|
+
},
|
|
448
|
+
query: function () {
|
|
449
|
+
return new Logger().query(...arguments);
|
|
450
|
+
},
|
|
451
|
+
connect: function () {
|
|
452
|
+
return new Logger().connect(...arguments);
|
|
453
|
+
},
|
|
454
|
+
remote: function () {
|
|
455
|
+
return new Logger().remote(...arguments);
|
|
456
|
+
},
|
|
457
|
+
loglevel: function () {
|
|
458
|
+
return new Logger().loglevel(...arguments);
|
|
434
459
|
}
|
|
435
|
-
|
|
436
460
|
});
|
|
437
461
|
Object.defineProperties(logger, {
|
|
438
462
|
Logger: {
|
|
@@ -506,7 +530,8 @@
|
|
|
506
530
|
|
|
507
531
|
};
|
|
508
532
|
|
|
509
|
-
async function request(path
|
|
533
|
+
async function request(path) {
|
|
534
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
510
535
|
let response = await request.fetch(`${info.address}${path}`, options); // maybe parse response body as json
|
|
511
536
|
|
|
512
537
|
if (typeof response.body === 'string' && response.headers['content-type'] === 'application/json') {
|
|
@@ -568,16 +593,19 @@
|
|
|
568
593
|
}
|
|
569
594
|
|
|
570
595
|
async function connectRemoteLogger() {
|
|
571
|
-
await src.remote(() => {
|
|
596
|
+
await src.remote(async () => {
|
|
572
597
|
let url = info.address.replace('http', 'ws');
|
|
573
598
|
|
|
574
599
|
if (process.env.__PERCY_BROWSERIFIED__) {
|
|
575
600
|
return new window.WebSocket(url);
|
|
576
601
|
} else {
|
|
577
|
-
|
|
602
|
+
/* eslint-disable-next-line import/no-extraneous-dependencies */
|
|
603
|
+
let {
|
|
604
|
+
default: WebSocket
|
|
605
|
+
} = await import('ws');
|
|
606
|
+
let ws = new WebSocket(url); // allow node to exit with an active connection
|
|
578
607
|
|
|
579
|
-
|
|
580
|
-
return socket;
|
|
608
|
+
return ws.once('open', () => ws._socket.unref());
|
|
581
609
|
}
|
|
582
610
|
});
|
|
583
611
|
} // Check if Percy is enabled using the healthcheck endpoint
|
|
@@ -656,7 +684,7 @@
|
|
|
656
684
|
|
|
657
685
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
658
686
|
|
|
659
|
-
})(this.PercySDKUtils = this.PercySDKUtils || {}, null
|
|
687
|
+
})(this.PercySDKUtils = this.PercySDKUtils || {}, null);
|
|
660
688
|
}).call(window);
|
|
661
689
|
|
|
662
690
|
if (typeof define === "function" && define.amd) {
|
package/dist/percy-dom.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.fetchPercyDOM = fetchPercyDOM;
|
|
7
8
|
|
|
8
9
|
var _percyInfo = _interopRequireDefault(require("./percy-info"));
|
|
9
10
|
|
|
@@ -19,4 +20,7 @@ async function fetchPercyDOM() {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
return _percyInfo.default.domScript;
|
|
22
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var _default = fetchPercyDOM;
|
|
26
|
+
exports.default = _default;
|
package/dist/percy-enabled.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.isPercyEnabled = isPercyEnabled;
|
|
7
8
|
|
|
8
9
|
var _logger = _interopRequireDefault(require("@percy/logger"));
|
|
9
10
|
|
|
@@ -13,18 +14,25 @@ var _request = _interopRequireDefault(require("./request"));
|
|
|
13
14
|
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
16
|
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
+
|
|
16
21
|
// Create a socket to connect to a remote logger
|
|
17
22
|
async function connectRemoteLogger() {
|
|
18
|
-
await _logger.default.remote(() => {
|
|
23
|
+
await _logger.default.remote(async () => {
|
|
19
24
|
let url = _percyInfo.default.address.replace('http', 'ws');
|
|
20
25
|
|
|
21
26
|
if (process.env.__PERCY_BROWSERIFIED__) {
|
|
22
27
|
return new window.WebSocket(url);
|
|
23
28
|
} else {
|
|
24
|
-
|
|
29
|
+
/* eslint-disable-next-line import/no-extraneous-dependencies */
|
|
30
|
+
let {
|
|
31
|
+
default: WebSocket
|
|
32
|
+
} = await Promise.resolve().then(() => _interopRequireWildcard(require('ws')));
|
|
33
|
+
let ws = new WebSocket(url); // allow node to exit with an active connection
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
return socket;
|
|
35
|
+
return ws.once('open', () => ws._socket.unref());
|
|
28
36
|
}
|
|
29
37
|
});
|
|
30
38
|
} // Check if Percy is enabled using the healthcheck endpoint
|
|
@@ -60,4 +68,7 @@ async function isPercyEnabled() {
|
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
return _percyInfo.default.enabled;
|
|
63
|
-
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var _default = isPercyEnabled;
|
|
74
|
+
exports.default = _default;
|
package/dist/post-snapshot.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.postSnapshot = postSnapshot;
|
|
7
8
|
|
|
8
9
|
var _percyInfo = _interopRequireDefault(require("./percy-info"));
|
|
9
10
|
|
|
@@ -22,4 +23,7 @@ async function postSnapshot(options, params) {
|
|
|
22
23
|
throw err;
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
|
-
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _default = postSnapshot;
|
|
29
|
+
exports.default = _default;
|
package/dist/request.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.request = request;
|
|
7
8
|
|
|
8
9
|
var _percyInfo = _interopRequireDefault(require("./percy-info"));
|
|
9
10
|
|
|
@@ -69,4 +70,7 @@ if (process.env.__PERCY_BROWSERIFIED__) {
|
|
|
69
70
|
}).on('error', reject).end(options.body);
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
|
-
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var _default = request;
|
|
76
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/sdk-utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.74",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/percy/cli",
|
|
8
|
+
"directory": "packages/sdk-utils"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
5
13
|
"main": "dist/index.js",
|
|
6
14
|
"browser": "dist/bundle.js",
|
|
7
15
|
"files": [
|
|
@@ -19,9 +27,6 @@
|
|
|
19
27
|
"test": "node ../../scripts/test",
|
|
20
28
|
"test:coverage": "yarn test --coverage"
|
|
21
29
|
},
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
24
|
-
},
|
|
25
30
|
"karma": {
|
|
26
31
|
"run_start": "node test/server start &",
|
|
27
32
|
"run_complete": "node test/server stop"
|
|
@@ -46,12 +51,7 @@
|
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@percy/logger": "1.0.0-beta.
|
|
50
|
-
},
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "https://github.com/percy/cli",
|
|
54
|
-
"directory": "packages/sdk-utils"
|
|
54
|
+
"@percy/logger": "1.0.0-beta.74"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "f8d1e38e93e5d731b8519d3fa8637e8a478efcde"
|
|
57
57
|
}
|
package/test/client.js
CHANGED
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
const ANSI_REG$1 = new RegExp('[\\u001B\\u009B][[\\]()#;?]*((?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)' + '|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))', 'g'); // color names by ansi escape code
|
|
40
40
|
|
|
41
41
|
const ANSI_COLORS = {
|
|
42
|
-
'
|
|
43
|
-
'
|
|
42
|
+
'91m': 'red',
|
|
43
|
+
'32m': 'green',
|
|
44
|
+
'93m': 'yellow',
|
|
44
45
|
'34m': 'blue',
|
|
45
|
-
'
|
|
46
|
+
'95m': 'magenta',
|
|
46
47
|
'90m': 'grey'
|
|
47
48
|
}; // colorize each line of a string using an ansi escape sequence
|
|
48
49
|
|
|
@@ -53,7 +54,8 @@
|
|
|
53
54
|
} // map ansi colors to bound colorize functions
|
|
54
55
|
|
|
55
56
|
|
|
56
|
-
const colors = entries(ANSI_COLORS).reduce((colors,
|
|
57
|
+
const colors = entries(ANSI_COLORS).reduce((colors, _ref) => {
|
|
58
|
+
let [code, name] = _ref;
|
|
57
59
|
return assign(colors, {
|
|
58
60
|
[name]: colorize.bind(null, code)
|
|
59
61
|
});
|
|
@@ -79,10 +81,11 @@
|
|
|
79
81
|
const NEWLINE_REG = /\r\n/g;
|
|
80
82
|
const LASTLINE_REG = /\n$/;
|
|
81
83
|
|
|
82
|
-
function sanitizeLog(str
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
function sanitizeLog(str) {
|
|
85
|
+
let {
|
|
86
|
+
ansi,
|
|
87
|
+
elapsed
|
|
88
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
86
89
|
// normalize line endings
|
|
87
90
|
str = str.replace(NEWLINE_REG, '\n'); // strip ansi colors
|
|
88
91
|
|
|
@@ -120,7 +123,11 @@
|
|
|
120
123
|
return object[method];
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
let spy = Object.assign(function spy(
|
|
126
|
+
let spy = Object.assign(function spy() {
|
|
127
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
128
|
+
args[_key] = arguments[_key];
|
|
129
|
+
}
|
|
130
|
+
|
|
124
131
|
spy.calls.push(args);
|
|
125
132
|
if (func) return func.apply(this, args);
|
|
126
133
|
}, {
|
|
@@ -182,14 +189,15 @@
|
|
|
182
189
|
|
|
183
190
|
let logs = Array.from(helpers$1.messages);
|
|
184
191
|
logger$1.loglevel('debug');
|
|
185
|
-
write(logger$1.format('
|
|
186
|
-
logs.reduce((lastlog, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
write(logger$1.format('testing', 'warn', '--- DUMPING LOGS ---'));
|
|
193
|
+
logs.reduce((lastlog, _ref) => {
|
|
194
|
+
let {
|
|
195
|
+
debug,
|
|
196
|
+
level,
|
|
197
|
+
message,
|
|
198
|
+
timestamp
|
|
199
|
+
} = _ref;
|
|
200
|
+
write(logger$1.format(debug, level, message, timestamp - lastlog));
|
|
193
201
|
return timestamp;
|
|
194
202
|
}, logs[0].timestamp);
|
|
195
203
|
}
|
|
@@ -225,7 +233,11 @@
|
|
|
225
233
|
};
|
|
226
234
|
|
|
227
235
|
if (process.env.__PERCY_BROWSERIFIED__) {
|
|
228
|
-
helpers.call = async function call(event
|
|
236
|
+
helpers.call = async function call(event) {
|
|
237
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
238
|
+
args[_key - 1] = arguments[_key];
|
|
239
|
+
}
|
|
240
|
+
|
|
229
241
|
let {
|
|
230
242
|
socket,
|
|
231
243
|
pending = {}
|
|
@@ -249,9 +261,10 @@
|
|
|
249
261
|
socket.onopen = socket.onerror = done;
|
|
250
262
|
});
|
|
251
263
|
|
|
252
|
-
socket.onmessage =
|
|
253
|
-
|
|
254
|
-
|
|
264
|
+
socket.onmessage = _ref => {
|
|
265
|
+
let {
|
|
266
|
+
data
|
|
267
|
+
} = _ref;
|
|
255
268
|
let {
|
|
256
269
|
id,
|
|
257
270
|
resolve,
|
package/test/server.js
CHANGED
|
@@ -123,12 +123,13 @@ async function start(args, log) {
|
|
|
123
123
|
close.called = true;
|
|
124
124
|
|
|
125
125
|
if (ctx) ctx.call('close');
|
|
126
|
+
for (let ws of wss.clients) ws.terminate();
|
|
126
127
|
wss.close(() => log('info', 'Closed SDK testing server'));
|
|
127
128
|
};
|
|
128
129
|
|
|
129
130
|
wss.on('connection', ws => {
|
|
130
131
|
ws.on('message', data => {
|
|
131
|
-
if (data === 'CLOSE') return close();
|
|
132
|
+
if (data.toString() === 'CLOSE') return close();
|
|
132
133
|
let { id, event, args = [] } = JSON.parse(data);
|
|
133
134
|
|
|
134
135
|
Promise.resolve().then(async () => {
|