@elastic/synthetics 1.0.0-beta.2 → 1.0.0-beta.20
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/CHANGELOG.md +228 -0
- package/NOTICE.txt +250 -0
- package/README.md +2 -1
- package/dist/cli.js +80 -49
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +77 -10
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +2 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/expect.d.ts +177 -0
- package/dist/core/expect.d.ts.map +1 -0
- package/dist/core/expect.js +33 -0
- package/dist/core/expect.js.map +1 -0
- package/dist/core/gatherer.d.ts +4 -7
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +33 -9
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +2 -15
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +54 -45
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +173 -63
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +13 -4
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +40 -1
- package/dist/dsl/journey.js.map +1 -1
- package/dist/formatter/javascript.d.ts +73 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +274 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/helpers.d.ts +33 -12
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +100 -46
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/parse_args.d.ts +5 -2
- package/dist/parse_args.d.ts.map +1 -1
- package/dist/parse_args.js +59 -16
- package/dist/parse_args.js.map +1 -1
- package/dist/plugins/browser-console.d.ts +5 -8
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +26 -7
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/network.d.ts +20 -20
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +110 -108
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +5 -5
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js +5 -5
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +11 -11
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +40 -24
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +10 -25
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +40 -26
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/reporters/base.d.ts +0 -1
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +22 -23
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/json.d.ts +43 -7
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +181 -35
- package/dist/reporters/json.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +304 -0
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -0
- package/dist/sdk/lh-trace-processor.js +832 -0
- package/dist/sdk/lh-trace-processor.js.map +1 -0
- package/dist/sdk/trace-metrics.d.ts +61 -0
- package/dist/sdk/trace-metrics.d.ts.map +1 -0
- package/dist/sdk/trace-metrics.js +252 -0
- package/dist/sdk/trace-metrics.js.map +1 -0
- package/dist/sdk/trace-processor.d.ts +106 -0
- package/dist/sdk/trace-processor.d.ts.map +1 -0
- package/dist/sdk/trace-processor.js +74 -0
- package/dist/sdk/trace-processor.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1575
- package/package.json +24 -13
- package/src/cli.ts +68 -45
- package/src/common_types.ts +92 -10
- package/src/config.ts +2 -5
- package/src/core/expect.ts +187 -0
- package/src/core/gatherer.ts +44 -23
- package/src/core/index.ts +6 -6
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +259 -112
- package/src/dsl/journey.ts +28 -6
- package/src/formatter/javascript.ts +330 -0
- package/src/helpers.ts +114 -24
- package/src/index.ts +7 -6
- package/src/parse_args.ts +97 -22
- package/src/plugins/browser-console.ts +30 -13
- package/src/plugins/network.ts +137 -144
- package/src/plugins/performance.ts +7 -7
- package/src/plugins/plugin-manager.ts +47 -36
- package/src/plugins/tracing.ts +43 -54
- package/src/reporters/base.ts +24 -23
- package/src/reporters/json.ts +251 -41
- package/src/sdk/lh-trace-processor.ts +1033 -0
- package/src/sdk/trace-metrics.ts +287 -0
- package/src/sdk/trace-processor.ts +147 -0
package/dist/index.js
CHANGED
|
@@ -27,9 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.after = exports.before = exports.step = exports.journey = exports.afterAll = exports.beforeAll = exports.run = void 0;
|
|
30
|
+
exports.expect = exports.after = exports.before = exports.step = exports.journey = exports.afterAll = exports.beforeAll = exports.run = void 0;
|
|
31
31
|
const core_1 = require("./core");
|
|
32
|
-
const logger_1 = require("./core/logger");
|
|
33
32
|
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
34
33
|
async function run(options) {
|
|
35
34
|
/**
|
|
@@ -38,11 +37,6 @@ async function run(options) {
|
|
|
38
37
|
source_map_support_1.default.install({
|
|
39
38
|
environment: 'node',
|
|
40
39
|
});
|
|
41
|
-
/**
|
|
42
|
-
* set up logger with appropriate file descriptor
|
|
43
|
-
* to capture all the DEBUG logs when run through heartbeat
|
|
44
|
-
*/
|
|
45
|
-
logger_1.setLogger(options.outfd);
|
|
46
40
|
try {
|
|
47
41
|
return await core_1.runner.run(options);
|
|
48
42
|
}
|
|
@@ -52,6 +46,9 @@ async function run(options) {
|
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
48
|
exports.run = run;
|
|
49
|
+
/**
|
|
50
|
+
* Export all core module functions
|
|
51
|
+
*/
|
|
55
52
|
var core_2 = require("./core");
|
|
56
53
|
Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return core_2.beforeAll; } });
|
|
57
54
|
Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return core_2.afterAll; } });
|
|
@@ -59,4 +56,6 @@ Object.defineProperty(exports, "journey", { enumerable: true, get: function () {
|
|
|
59
56
|
Object.defineProperty(exports, "step", { enumerable: true, get: function () { return core_2.step; } });
|
|
60
57
|
Object.defineProperty(exports, "before", { enumerable: true, get: function () { return core_2.before; } });
|
|
61
58
|
Object.defineProperty(exports, "after", { enumerable: true, get: function () { return core_2.after; } });
|
|
59
|
+
var expect_1 = require("./core/expect");
|
|
60
|
+
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return expect_1.expect; } });
|
|
62
61
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,iCAAgC;AAEhC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,iCAAgC;AAEhC,4EAAkD;AAE3C,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C;;OAEG;IACH,4BAAgB,CAAC,OAAO,CAAC;QACvB,WAAW,EAAE,MAAM;KACpB,CAAC,CAAC;IAEH,IAAI;QACF,OAAO,MAAM,aAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAClC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC;AAdD,kBAcC;AAED;;GAEG;AACH,+BAA2E;AAAlE,iGAAA,SAAS,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAAE,+FAAA,OAAO,OAAA;AAAE,4FAAA,IAAI,OAAA;AAAE,8FAAA,MAAM,OAAA;AAAE,6FAAA,KAAK,OAAA;AAC1D,wCAAuC;AAA9B,gGAAA,MAAM,OAAA"}
|
package/dist/parse_args.d.ts
CHANGED
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
import { CliArgs } from './common_types';
|
|
26
|
+
declare const command: import("commander").Command;
|
|
27
|
+
declare const options: CliArgs;
|
|
28
|
+
export { options };
|
|
29
|
+
export default command;
|
|
27
30
|
//# sourceMappingURL=parse_args.d.ts.map
|
package/dist/parse_args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse_args.d.ts","sourceRoot":"","sources":["../src/parse_args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"parse_args.d.ts","sourceRoot":"","sources":["../src/parse_args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAuFzC,QAAA,MAAM,OAAO,6BAA8B,CAAC;AAC5C,QAAA,MAAM,OAAO,SAA4B,CAAC;AA0C1C,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,eAAe,OAAO,CAAC"}
|
package/dist/parse_args.js
CHANGED
|
@@ -23,38 +23,81 @@
|
|
|
23
23
|
* THE SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
+
var _a;
|
|
26
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.options = void 0;
|
|
27
29
|
const commander_1 = require("commander");
|
|
28
30
|
const reporters_1 = require("./reporters");
|
|
29
|
-
const
|
|
30
|
-
.map(r => String(r))
|
|
31
|
-
.join();
|
|
31
|
+
const helpers_1 = require("./helpers");
|
|
32
32
|
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
33
33
|
const { name, version } = require('../package.json');
|
|
34
34
|
commander_1.program
|
|
35
35
|
.name(`npx ${name}`)
|
|
36
36
|
.usage('[options] [dir] [files] file')
|
|
37
37
|
.option('-c, --config <path>', 'configuration path (default: synthetics.config.js)')
|
|
38
|
-
.option('-
|
|
39
|
-
.
|
|
40
|
-
.option('-j, --json', 'output newline delimited JSON')
|
|
41
|
-
.option('--reporter <reporter>', `output repoter format, can be one of ${availableReporters}`)
|
|
38
|
+
.option('-p, --params <jsonstring>', 'JSON object that gets injected to all journeys', JSON.parse)
|
|
39
|
+
.addOption(new commander_1.Option('--reporter <value>', `output repoter format`).choices(Object.keys(reporters_1.reporters)))
|
|
42
40
|
.option('-d, --debug', 'print debug logs info')
|
|
43
41
|
.option('--pattern <pattern>', 'RegExp file patterns to search inside directory')
|
|
44
42
|
.option('--inline', 'Run inline journeys from heartbeat')
|
|
45
43
|
.option('-r, --require <modules...>', 'module(s) to preload')
|
|
46
44
|
.option('--no-headless', 'run browser in headful mode')
|
|
47
|
-
.option('--sandbox', 'enable chromium sandboxing')
|
|
48
|
-
.option('--
|
|
49
|
-
.option('--
|
|
50
|
-
.
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
.option('--metrics', 'capture performance metrics for each step')
|
|
45
|
+
.option('--sandbox', 'enable chromium sandboxing', false)
|
|
46
|
+
.option('--rich-events', 'Mimics a heartbeat run')
|
|
47
|
+
.option('--capability <features...>', 'Enable capabilities through feature flags')
|
|
48
|
+
.addOption(new commander_1.Option('--screenshots [flag]', 'take screenshots at end of each step')
|
|
49
|
+
.choices(['on', 'off', 'only-on-failure'])
|
|
50
|
+
.default('on'))
|
|
54
51
|
.option('--dry-run', "don't actually execute anything, report only registered journeys")
|
|
55
|
-
.option('--
|
|
52
|
+
.option('--match <name>', 'run only journeys with a name or tags that matches the glob')
|
|
53
|
+
.option('--tags <name...>', 'run only journeys with the given tag(s), or globs')
|
|
56
54
|
.option('--outfd <fd>', 'specify a file descriptor for logs. Default is stdout', parseInt)
|
|
55
|
+
.option('--ws-endpoint <endpoint>', 'Browser WebSocket endpoint to connect to')
|
|
56
|
+
.option('--pause-on-error', 'pause on error until a keypress is made in the console. Useful during development')
|
|
57
|
+
.option('--ignore-https-errors', 'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!')
|
|
58
|
+
.option('--quiet-exit-code', 'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run')
|
|
59
|
+
.addOption(new commander_1.Option('--throttling <d/u/l>', 'List of options to throttle network conditions for download throughput (d) in megabits/second, upload throughput (u) in megabits/second and latency (l) in milliseconds.').default(helpers_1.DEFAULT_NETWORK_CONDITIONS_ARG))
|
|
60
|
+
.option('--no-throttling', 'Turns off default network throttling.')
|
|
61
|
+
.option('--playwright-options <jsonstring>', 'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file. Options defined via --playwright-options take precedence.', JSON.parse)
|
|
57
62
|
.version(version)
|
|
58
63
|
.description('Run synthetic tests');
|
|
59
|
-
|
|
64
|
+
const command = commander_1.program.parse(process.argv);
|
|
65
|
+
const options = command.opts();
|
|
66
|
+
exports.options = options;
|
|
67
|
+
/**
|
|
68
|
+
* Group all events that can be consumed by heartbeat and
|
|
69
|
+
* eventually by the Synthetics UI.
|
|
70
|
+
*/
|
|
71
|
+
if (options.richEvents) {
|
|
72
|
+
options.reporter = (_a = options.reporter) !== null && _a !== void 0 ? _a : 'json';
|
|
73
|
+
options.ssblocks = true;
|
|
74
|
+
options.network = true;
|
|
75
|
+
options.quietExitCode = true;
|
|
76
|
+
options.trace = true;
|
|
77
|
+
}
|
|
78
|
+
if (options.capability) {
|
|
79
|
+
const supportedCapabilities = [
|
|
80
|
+
'trace',
|
|
81
|
+
'network',
|
|
82
|
+
'filmstrips',
|
|
83
|
+
'metrics',
|
|
84
|
+
'ssblocks',
|
|
85
|
+
];
|
|
86
|
+
/**
|
|
87
|
+
* trace - record chrome trace events(LCP, FCP, CLS, etc.) for all journeys
|
|
88
|
+
* network - capture network information for all journeys
|
|
89
|
+
* filmstrips - record detailed filmstrips for all journeys
|
|
90
|
+
* metrics - capture performance metrics (DOM Nodes, Heap size, etc.) for each step
|
|
91
|
+
* ssblocks - Dedupes the screenshots in to blocks to save storage space
|
|
92
|
+
*/
|
|
93
|
+
for (const flag of options.capability) {
|
|
94
|
+
if (supportedCapabilities.includes(flag)) {
|
|
95
|
+
options[flag] = true;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.warn(`Missing capability "${flag}", current supported capabilities are ${supportedCapabilities.join(', ')}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.default = command;
|
|
60
103
|
//# sourceMappingURL=parse_args.js.map
|
package/dist/parse_args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse_args.js","sourceRoot":"","sources":["../src/parse_args.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"parse_args.js","sourceRoot":"","sources":["../src/parse_args.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;AAEH,yCAA4C;AAE5C,2CAAwC;AACxC,uCAA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,CAAC,IAAI,CAC5F,IAAI,CACL,EAAE,CACJ,CAAC;SACH;KACF;CACF;AAGD,kBAAe,OAAO,CAAC"}
|
|
@@ -22,19 +22,16 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
26
|
-
import { DefaultPluginOutput } from '../common_types';
|
|
25
|
+
import { BrowserMessage, Driver } from '../common_types';
|
|
27
26
|
import { Step } from '../dsl';
|
|
28
|
-
export declare type BrowserMessage = {
|
|
29
|
-
text: string;
|
|
30
|
-
type: string;
|
|
31
|
-
} & DefaultPluginOutput;
|
|
32
27
|
export declare class BrowserConsole {
|
|
33
|
-
private
|
|
28
|
+
private driver;
|
|
34
29
|
private messages;
|
|
35
30
|
_currentStep: Partial<Step>;
|
|
31
|
+
constructor(driver: Driver);
|
|
36
32
|
private consoleEventListener;
|
|
37
|
-
|
|
33
|
+
private pageErrorEventListener;
|
|
34
|
+
private enforceMessagesLimit;
|
|
38
35
|
start(): void;
|
|
39
36
|
stop(): BrowserMessage[];
|
|
40
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-console.d.ts","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"browser-console.d.ts","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B,qBAAa,cAAc;IAIb,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,QAAQ,CAAwB;IACxC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAQ;gBAEf,MAAM,EAAE,MAAM;IAElC,OAAO,CAAC,oBAAoB,CAgB1B;IAEF,OAAO,CAAC,sBAAsB,CAc5B;IAEF,OAAO,CAAC,oBAAoB;IAM5B,KAAK;IAKL,IAAI;CAKL"}
|
|
@@ -28,8 +28,8 @@ exports.BrowserConsole = void 0;
|
|
|
28
28
|
const helpers_1 = require("../helpers");
|
|
29
29
|
const defaultMessageLimit = 1000;
|
|
30
30
|
class BrowserConsole {
|
|
31
|
-
constructor(
|
|
32
|
-
this.
|
|
31
|
+
constructor(driver) {
|
|
32
|
+
this.driver = driver;
|
|
33
33
|
this.messages = [];
|
|
34
34
|
this._currentStep = null;
|
|
35
35
|
this.consoleEventListener = msg => {
|
|
@@ -45,17 +45,36 @@ class BrowserConsole {
|
|
|
45
45
|
type,
|
|
46
46
|
step: { name, index },
|
|
47
47
|
});
|
|
48
|
-
|
|
49
|
-
this.messages.splice(0, 1);
|
|
50
|
-
}
|
|
48
|
+
this.enforceMessagesLimit();
|
|
51
49
|
}
|
|
52
50
|
};
|
|
51
|
+
this.pageErrorEventListener = (error) => {
|
|
52
|
+
if (!this._currentStep) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const { name, index } = this._currentStep;
|
|
56
|
+
this.messages.push({
|
|
57
|
+
timestamp: helpers_1.getTimestamp(),
|
|
58
|
+
text: error.message,
|
|
59
|
+
type: 'error',
|
|
60
|
+
step: { name, index },
|
|
61
|
+
error,
|
|
62
|
+
});
|
|
63
|
+
this.enforceMessagesLimit();
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
enforceMessagesLimit() {
|
|
67
|
+
if (this.messages.length > defaultMessageLimit) {
|
|
68
|
+
this.messages.splice(0, 1);
|
|
69
|
+
}
|
|
53
70
|
}
|
|
54
71
|
start() {
|
|
55
|
-
this.page.on('console', this.consoleEventListener);
|
|
72
|
+
this.driver.page.on('console', this.consoleEventListener);
|
|
73
|
+
this.driver.page.on('pageerror', this.pageErrorEventListener);
|
|
56
74
|
}
|
|
57
75
|
stop() {
|
|
58
|
-
this.page.off('console', this.consoleEventListener);
|
|
76
|
+
this.driver.page.off('console', this.consoleEventListener);
|
|
77
|
+
this.driver.page.off('pageerror', this.pageErrorEventListener);
|
|
59
78
|
return this.messages;
|
|
60
79
|
}
|
|
61
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-console.js","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;
|
|
1
|
+
{"version":3,"file":"browser-console.js","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,wCAA0C;AAE1C,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAa,cAAc;IAIzB,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAH1B,aAAQ,GAAqB,EAAE,CAAC;QACxC,iBAAY,GAAkB,IAAI,CAAC;QAI3B,yBAAoB,GAAG,GAAG,CAAC,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,OAAO;aACR;YACD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,SAAS,EAAE;gBAC1C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC1C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACjB,SAAS,EAAE,sBAAY,EAAE;oBACzB,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;oBAChB,IAAI;oBACJ,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;iBACtB,CAAC,CAAC;gBAEH,IAAI,CAAC,oBAAoB,EAAE,CAAC;aAC7B;QACH,CAAC,CAAC;QAEM,2BAAsB,GAAG,CAAC,KAAY,EAAE,EAAE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Protocol } from 'playwright-chromium/types/protocol';
|
|
27
|
-
import { NetworkInfo } from '../common_types';
|
|
26
|
+
import { NetworkInfo, Driver } from '../common_types';
|
|
28
27
|
import { Step } from '../dsl';
|
|
29
28
|
export declare class NetworkManager {
|
|
29
|
+
private driver;
|
|
30
30
|
private _browser;
|
|
31
31
|
private _InflightRequestMap;
|
|
32
32
|
results: Array<NetworkInfo>;
|
|
33
33
|
_currentStep: Partial<Step>;
|
|
34
|
-
|
|
34
|
+
constructor(driver: Driver);
|
|
35
|
+
start(): Promise<void>;
|
|
35
36
|
_findNetworkRecord(requestId: string): NetworkInfo;
|
|
36
37
|
_onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload): void;
|
|
37
38
|
_onRequestWillBeSentExtraInfo(event: Protocol.Network.requestWillBeSentExtraInfoPayload): void;
|
|
@@ -44,23 +45,22 @@ export declare class NetworkManager {
|
|
|
44
45
|
* Account for missing response received event and also adjust the
|
|
45
46
|
* response received event based on when first byte event was recorded
|
|
46
47
|
*/
|
|
47
|
-
getResponseReceivedTime(timing: Protocol.Network.Response['timing'], responseReceivedTime: number): number;
|
|
48
|
-
/**
|
|
49
|
-
* The timing calculations are based on the chrome devtools frontend
|
|
50
|
-
* https://github.com/ChromeDevTools/devtools-frontend/blob/7f5478d8ceb7586f23f4073ab5c2085dac1ec26a/front_end/network/RequestTimingView.js#L98-L193
|
|
51
|
-
*/
|
|
52
|
-
calculateTimings(record: NetworkInfo): {
|
|
53
|
-
blocked: number;
|
|
54
|
-
queueing: number;
|
|
55
|
-
dns: number;
|
|
56
|
-
ssl: number;
|
|
57
|
-
proxy: number;
|
|
58
|
-
connect: number;
|
|
59
|
-
send: number;
|
|
60
|
-
wait: number;
|
|
61
|
-
receive: number;
|
|
62
|
-
total: number;
|
|
63
|
-
};
|
|
64
48
|
stop(): NetworkInfo[];
|
|
65
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The timing calculations are based on the chrome devtools frontend
|
|
52
|
+
* https://github.com/ChromeDevTools/devtools-frontend/blob/7f5478d8ceb7586f23f4073ab5c2085dac1ec26a/front_end/network/RequestTimingView.js#L98-L193
|
|
53
|
+
*/
|
|
54
|
+
export declare function calculateTimings(record: NetworkInfo): {
|
|
55
|
+
blocked: number;
|
|
56
|
+
queueing: number;
|
|
57
|
+
dns: number;
|
|
58
|
+
ssl: number;
|
|
59
|
+
proxy: number;
|
|
60
|
+
connect: number;
|
|
61
|
+
send: number;
|
|
62
|
+
wait: number;
|
|
63
|
+
receive: number;
|
|
64
|
+
total: number;
|
|
65
|
+
};
|
|
66
66
|
//# sourceMappingURL=network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/plugins/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/plugins/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAe,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,qBAAa,cAAc;IAMb,OAAO,CAAC,MAAM;IAL1B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,mBAAmB,CAAkC;IAC7D,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAM;IACjC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAQ;gBAEf,MAAM,EAAE,MAAM;IAE5B,KAAK;IAuBX,kBAAkB,CAAC,SAAS,EAAE,MAAM;IAIpC,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,wBAAwB;IAqErE,6BAA6B,CAC3B,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,iCAAiC;IAgB3D,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB;IAU3D,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,uBAAuB;IAcnE,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB;IAKjE,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,oBAAoB;IAK7D,iBAAiB,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,MAAM;IAmB5B;;;OAGG;IAEH,IAAI;CAGL;AAoBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW;;;;;;;;;;;EAsHnD"}
|
package/dist/plugins/network.js
CHANGED
|
@@ -24,15 +24,17 @@
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.NetworkManager = void 0;
|
|
27
|
+
exports.calculateTimings = exports.NetworkManager = void 0;
|
|
28
28
|
const helpers_1 = require("../helpers");
|
|
29
29
|
class NetworkManager {
|
|
30
|
-
constructor() {
|
|
30
|
+
constructor(driver) {
|
|
31
|
+
this.driver = driver;
|
|
31
32
|
this._InflightRequestMap = new Map();
|
|
32
33
|
this.results = [];
|
|
33
34
|
this._currentStep = null;
|
|
34
35
|
}
|
|
35
|
-
async start(
|
|
36
|
+
async start() {
|
|
37
|
+
const { client } = this.driver;
|
|
36
38
|
const { product } = await client.send('Browser.getVersion');
|
|
37
39
|
const [name, version] = product.split('/');
|
|
38
40
|
this._browser = { name, version };
|
|
@@ -167,7 +169,7 @@ class NetworkManager {
|
|
|
167
169
|
record.transferSize = encodedDataLength;
|
|
168
170
|
}
|
|
169
171
|
record.loadEndTime = endTime;
|
|
170
|
-
record.timings =
|
|
172
|
+
record.timings = calculateTimings(record);
|
|
171
173
|
this.results.push(record);
|
|
172
174
|
/**
|
|
173
175
|
* When there is DNS failure, browsers keeps retrying requests which
|
|
@@ -179,120 +181,120 @@ class NetworkManager {
|
|
|
179
181
|
* Account for missing response received event and also adjust the
|
|
180
182
|
* response received event based on when first byte event was recorded
|
|
181
183
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
responseReceivedTime > headersReceivedTime) {
|
|
190
|
-
responseReceivedTime = headersReceivedTime;
|
|
191
|
-
}
|
|
192
|
-
if (startTime > responseReceivedTime) {
|
|
193
|
-
responseReceivedTime = startTime;
|
|
194
|
-
}
|
|
184
|
+
stop() {
|
|
185
|
+
return this.results;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.NetworkManager = NetworkManager;
|
|
189
|
+
function getResponseReceivedTime(timing, responseReceivedTime) {
|
|
190
|
+
if (timing == null) {
|
|
195
191
|
return responseReceivedTime;
|
|
196
192
|
}
|
|
193
|
+
const startTime = timing.requestTime;
|
|
194
|
+
const headersReceivedTime = startTime + timing.receiveHeadersEnd / 1000;
|
|
195
|
+
if (responseReceivedTime < 0 || responseReceivedTime > headersReceivedTime) {
|
|
196
|
+
responseReceivedTime = headersReceivedTime;
|
|
197
|
+
}
|
|
198
|
+
if (startTime > responseReceivedTime) {
|
|
199
|
+
responseReceivedTime = startTime;
|
|
200
|
+
}
|
|
201
|
+
return responseReceivedTime;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The timing calculations are based on the chrome devtools frontend
|
|
205
|
+
* https://github.com/ChromeDevTools/devtools-frontend/blob/7f5478d8ceb7586f23f4073ab5c2085dac1ec26a/front_end/network/RequestTimingView.js#L98-L193
|
|
206
|
+
*/
|
|
207
|
+
function calculateTimings(record) {
|
|
208
|
+
const result = {
|
|
209
|
+
blocked: -1,
|
|
210
|
+
queueing: -1,
|
|
211
|
+
proxy: -1,
|
|
212
|
+
dns: -1,
|
|
213
|
+
ssl: -1,
|
|
214
|
+
connect: -1,
|
|
215
|
+
send: -1,
|
|
216
|
+
wait: -1,
|
|
217
|
+
receive: -1,
|
|
218
|
+
total: -1,
|
|
219
|
+
};
|
|
220
|
+
const { requestSentTime, loadEndTime, responseReceivedTime } = record;
|
|
197
221
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
222
|
+
* Handle when request failed and no responseReceived event was
|
|
223
|
+
* fired for that particular request
|
|
224
|
+
* Eg: connection refused by remote host
|
|
200
225
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
send: -1,
|
|
210
|
-
wait: -1,
|
|
211
|
-
receive: -1,
|
|
212
|
-
total: -1,
|
|
213
|
-
};
|
|
214
|
-
const { requestSentTime, loadEndTime, responseReceivedTime } = record;
|
|
215
|
-
/**
|
|
216
|
-
* Handle when request failed and no responseReceived event was
|
|
217
|
-
* fired for that particular request
|
|
218
|
-
* Eg: connection refused by remote host
|
|
219
|
-
*/
|
|
220
|
-
const response = record.response || {
|
|
221
|
-
timing: null,
|
|
222
|
-
fromServiceWorker: false,
|
|
223
|
-
};
|
|
224
|
-
const toMilliseconds = (time) => (time === -1 ? -1 : time * 1000);
|
|
225
|
-
const calculateDiffInMs = (name, start, end) => {
|
|
226
|
-
if (start < Number.MAX_VALUE && start <= end) {
|
|
227
|
-
result[name] = toMilliseconds(end - start);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
const firstPositive = (numbers) => {
|
|
231
|
-
for (let i = 0; i < numbers.length; ++i) {
|
|
232
|
-
if (numbers[i] > 0) {
|
|
233
|
-
return numbers[i];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return null;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* requestTime is baseline in seconds, rest of the timing data are ticks in milliseconds
|
|
240
|
-
* from the requestTime, so we calculate the offset from that
|
|
241
|
-
*/
|
|
242
|
-
const addOffsetRange = (name, start, end) => {
|
|
243
|
-
if (start >= 0 && end >= 0) {
|
|
244
|
-
calculateDiffInMs(name, startTime + start / 1000, startTime + end / 1000);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
const timing = response.timing;
|
|
248
|
-
const actResRcvdTime = this.getResponseReceivedTime(timing, responseReceivedTime);
|
|
249
|
-
const issueTime = requestSentTime;
|
|
250
|
-
const startTime = timing == null ? -1 : timing.requestTime;
|
|
251
|
-
const endTime = firstPositive([loadEndTime, actResRcvdTime]) || startTime;
|
|
252
|
-
if (timing == null) {
|
|
253
|
-
const start = issueTime !== -1 ? issueTime : startTime !== -1 ? startTime : 0;
|
|
254
|
-
const middle = actResRcvdTime === -1 ? Number.MAX_VALUE : actResRcvdTime;
|
|
255
|
-
const end = endTime === -1 ? Number.MAX_VALUE : endTime;
|
|
256
|
-
calculateDiffInMs('total', start, end);
|
|
257
|
-
calculateDiffInMs('blocked', start, middle);
|
|
258
|
-
calculateDiffInMs('receive', middle, end);
|
|
259
|
-
// Check if the request is blocked/stalled for the whole timeframe and
|
|
260
|
-
// calculate timings appropriately for that request
|
|
261
|
-
if (!isFinite(result['blocked'])) {
|
|
262
|
-
result['blocked'] = result['total'];
|
|
263
|
-
}
|
|
264
|
-
return result;
|
|
226
|
+
const response = record.response || {
|
|
227
|
+
timing: null,
|
|
228
|
+
fromServiceWorker: false,
|
|
229
|
+
};
|
|
230
|
+
const toMilliseconds = (time) => (time === -1 ? -1 : time * 1000);
|
|
231
|
+
const calculateDiffInMs = (name, start, end) => {
|
|
232
|
+
if (start < Number.MAX_VALUE && start <= end) {
|
|
233
|
+
result[name] = toMilliseconds(end - start);
|
|
265
234
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
235
|
+
};
|
|
236
|
+
const firstPositive = (numbers) => {
|
|
237
|
+
for (let i = 0; i < numbers.length; ++i) {
|
|
238
|
+
if (numbers[i] > 0) {
|
|
239
|
+
return numbers[i];
|
|
240
|
+
}
|
|
269
241
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
242
|
+
return null;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* requestTime is baseline in seconds, rest of the timing data are ticks in milliseconds
|
|
246
|
+
* from the requestTime, so we calculate the offset from that
|
|
247
|
+
*/
|
|
248
|
+
const addOffsetRange = (name, start, end) => {
|
|
249
|
+
if (start >= 0 && end >= 0) {
|
|
250
|
+
calculateDiffInMs(name, startTime + start / 1000, startTime + end / 1000);
|
|
274
251
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
252
|
+
};
|
|
253
|
+
const timing = response.timing;
|
|
254
|
+
const actResRcvdTime = getResponseReceivedTime(timing, responseReceivedTime);
|
|
255
|
+
const issueTime = requestSentTime;
|
|
256
|
+
const startTime = timing == null ? -1 : timing.requestTime;
|
|
257
|
+
const endTime = firstPositive([loadEndTime, actResRcvdTime]) || startTime;
|
|
258
|
+
if (timing == null) {
|
|
259
|
+
const start = issueTime !== -1 ? issueTime : startTime !== -1 ? startTime : 0;
|
|
260
|
+
const middle = actResRcvdTime === -1 ? Number.MAX_VALUE : actResRcvdTime;
|
|
261
|
+
const end = endTime === -1 ? Number.MAX_VALUE : endTime;
|
|
262
|
+
calculateDiffInMs('total', start, end);
|
|
263
|
+
calculateDiffInMs('blocked', start, middle);
|
|
264
|
+
calculateDiffInMs('receive', middle, end);
|
|
265
|
+
// Check if the request is blocked/stalled for the whole timeframe and
|
|
266
|
+
// calculate timings appropriately for that request
|
|
267
|
+
if (!isFinite(result['blocked'])) {
|
|
268
|
+
result['blocked'] = result['total'];
|
|
289
269
|
}
|
|
290
|
-
calculateDiffInMs('receive', actResRcvdTime, endTime);
|
|
291
270
|
return result;
|
|
292
271
|
}
|
|
293
|
-
|
|
294
|
-
|
|
272
|
+
calculateDiffInMs('total', issueTime < startTime ? issueTime : startTime, endTime);
|
|
273
|
+
if (issueTime < startTime) {
|
|
274
|
+
calculateDiffInMs('queueing', issueTime, startTime);
|
|
275
|
+
}
|
|
276
|
+
const responseReceived = toMilliseconds(actResRcvdTime - startTime);
|
|
277
|
+
if (response.fromServiceWorker) {
|
|
278
|
+
addOffsetRange('blocked', 0, timing.workerStart);
|
|
279
|
+
addOffsetRange('wait', timing.sendEnd, responseReceived);
|
|
295
280
|
}
|
|
281
|
+
else if (!timing.pushStart) {
|
|
282
|
+
const blockingEnd = firstPositive([
|
|
283
|
+
timing.dnsStart,
|
|
284
|
+
timing.connectStart,
|
|
285
|
+
timing.sendStart,
|
|
286
|
+
responseReceived,
|
|
287
|
+
]) || 0;
|
|
288
|
+
addOffsetRange('blocked', 0, blockingEnd);
|
|
289
|
+
addOffsetRange('proxy', timing.proxyStart, timing.proxyEnd);
|
|
290
|
+
addOffsetRange('dns', timing.dnsStart, timing.dnsEnd);
|
|
291
|
+
addOffsetRange('connect', timing.connectStart, timing.connectEnd);
|
|
292
|
+
addOffsetRange('ssl', timing.sslStart, timing.sslEnd);
|
|
293
|
+
addOffsetRange('send', timing.sendStart, timing.sendEnd);
|
|
294
|
+
addOffsetRange('wait', Math.max(timing.sendEnd, timing.connectEnd, timing.dnsEnd, timing.proxyEnd, blockingEnd), responseReceived);
|
|
295
|
+
}
|
|
296
|
+
calculateDiffInMs('receive', actResRcvdTime, endTime);
|
|
297
|
+
return result;
|
|
296
298
|
}
|
|
297
|
-
exports.
|
|
299
|
+
exports.calculateTimings = calculateTimings;
|
|
298
300
|
//# sourceMappingURL=network.js.map
|