@elastic/synthetics 1.0.0-beta.25 → 1.0.0-beta.26
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/README.md +1 -1
- package/dist/cli.js +42 -5
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +59 -5
- package/dist/common_types.d.ts.map +1 -1
- package/dist/core/gatherer.d.ts +2 -2
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +15 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/runner.d.ts +10 -58
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +88 -49
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +3 -0
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +15 -0
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +64 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +62 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/generator/index.d.ts +13 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +123 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.js → generator/utils.d.ts} +3 -3
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +44 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +12 -6
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +33 -43
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/loader.js +4 -4
- package/dist/loader.js.map +1 -1
- package/dist/options.d.ts +12 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +66 -4
- package/dist/options.js.map +1 -1
- package/dist/plugins/performance.d.ts +1 -16
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +119 -0
- package/dist/push/bundler.js.map +1 -0
- package/{src/reporters/reporter.ts → dist/push/index.d.ts} +4 -11
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +58 -0
- package/dist/push/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → push/monitor.d.ts} +7 -8
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +67 -0
- package/dist/push/monitor.js.map +1 -0
- package/dist/push/plugin.d.ts +33 -0
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +123 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +43 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +95 -0
- package/dist/push/request.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +45 -47
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +7 -3
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +118 -118
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +91 -86
- package/dist/reporters/junit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -8
- package/src/cli.ts +65 -9
- package/src/common_types.ts +69 -5
- package/src/core/gatherer.ts +2 -2
- package/src/core/index.ts +15 -0
- package/src/core/runner.ts +86 -113
- package/src/dsl/journey.ts +18 -0
- package/src/dsl/monitor.ts +83 -0
- package/src/generator/index.ts +159 -0
- package/src/generator/utils.ts +41 -0
- package/src/helpers.ts +36 -52
- package/src/index.ts +9 -1
- package/src/loader.ts +4 -4
- package/src/options.ts +71 -8
- package/src/plugins/performance.ts +1 -17
- package/src/push/bundler.ts +99 -0
- package/src/push/index.ts +63 -0
- package/src/push/monitor.ts +77 -0
- package/src/push/plugin.ts +113 -0
- package/src/push/request.ts +123 -0
- package/src/reporters/base.ts +57 -56
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +153 -145
- package/src/reporters/junit.ts +98 -93
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/synthetics.config.ts +19 -0
- package/CHANGELOG.md +0 -348
- package/NOTICE.txt +0 -221
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2020-present, Elastic NV
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in
|
|
15
|
+
* all copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
* THE SOFTWARE.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.formatStaleMonitors = exports.formatFailedMonitors = exports.formatAPIError = exports.formatNotFoundError = exports.createMonitors = exports.ok = void 0;
|
|
28
|
+
const colors_1 = require("kleur/colors");
|
|
29
|
+
const undici_1 = require("undici");
|
|
30
|
+
const helpers_1 = require("../helpers");
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
32
|
+
const { version } = require('../../package.json');
|
|
33
|
+
function encodeAuth(auth) {
|
|
34
|
+
if (auth.includes(':')) {
|
|
35
|
+
return Buffer.from(auth).toString('base64');
|
|
36
|
+
}
|
|
37
|
+
return auth;
|
|
38
|
+
}
|
|
39
|
+
function getAPIUrl(options) {
|
|
40
|
+
return (options.url + `/s/${options.space}/api/synthetics/service/project/monitors`);
|
|
41
|
+
}
|
|
42
|
+
function ok(statusCode) {
|
|
43
|
+
return statusCode >= 200 && statusCode <= 299;
|
|
44
|
+
}
|
|
45
|
+
exports.ok = ok;
|
|
46
|
+
async function createMonitors(monitors, options) {
|
|
47
|
+
const schema = {
|
|
48
|
+
project: options.project,
|
|
49
|
+
keep_stale: !options.delete,
|
|
50
|
+
monitors,
|
|
51
|
+
};
|
|
52
|
+
return await (0, undici_1.request)(getAPIUrl(options), {
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
body: JSON.stringify(schema),
|
|
55
|
+
headers: {
|
|
56
|
+
authorization: `Basic ${encodeAuth(options.auth)}`,
|
|
57
|
+
'content-type': 'application/json',
|
|
58
|
+
'user-agent': `Elastic/Synthetics ${version}`,
|
|
59
|
+
'kbn-xsrf': 'true',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.createMonitors = createMonitors;
|
|
64
|
+
function formatNotFoundError(message) {
|
|
65
|
+
return (0, colors_1.bold)(`${helpers_1.symbols['failed']} Please check your kibana url and try again - 404:${message}`);
|
|
66
|
+
}
|
|
67
|
+
exports.formatNotFoundError = formatNotFoundError;
|
|
68
|
+
function formatAPIError(statuCode, error, message) {
|
|
69
|
+
let outer = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
70
|
+
let inner = (0, colors_1.bold)(`${helpers_1.symbols['failed']} monitor creation failed - ${statuCode}:${error}\n`);
|
|
71
|
+
inner += (0, helpers_1.indent)(message, ' ');
|
|
72
|
+
outer += (0, helpers_1.indent)(inner);
|
|
73
|
+
return outer;
|
|
74
|
+
}
|
|
75
|
+
exports.formatAPIError = formatAPIError;
|
|
76
|
+
function formatFailedMonitors(errors) {
|
|
77
|
+
let outer = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
78
|
+
for (const error of errors) {
|
|
79
|
+
const monitorId = error.id ? `: monitor(${error.id})` : '';
|
|
80
|
+
let inner = (0, colors_1.bold)(`> ${error.reason}${monitorId}\n`);
|
|
81
|
+
inner += (0, helpers_1.indent)(error.details, ' ');
|
|
82
|
+
outer += (0, helpers_1.indent)(inner) + '\n';
|
|
83
|
+
outer += '\n';
|
|
84
|
+
}
|
|
85
|
+
return outer;
|
|
86
|
+
}
|
|
87
|
+
exports.formatFailedMonitors = formatFailedMonitors;
|
|
88
|
+
function formatStaleMonitors() {
|
|
89
|
+
let outer = (0, colors_1.bold)((0, colors_1.yellow)(`${helpers_1.symbols['warning']} Found stale monitors\n`));
|
|
90
|
+
const inner = (0, colors_1.gray)(`Pass --delete to remove all the stale monitors.`);
|
|
91
|
+
outer += (0, helpers_1.indent)(inner, ' ');
|
|
92
|
+
return outer;
|
|
93
|
+
}
|
|
94
|
+
exports.formatStaleMonitors = formatStaleMonitors;
|
|
95
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/push/request.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,yCAAkD;AAClD,mCAAiC;AAEjC,wCAA6C;AAG7C,uDAAuD;AACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAQlD,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC7C;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,SAAS,CAAC,OAAoB;IACrC,OAAO,CACL,OAAO,CAAC,GAAG,GAAG,MAAM,OAAO,CAAC,KAAK,0CAA0C,CAC5E,CAAC;AACJ,CAAC;AAED,SAAgB,EAAE,CAAC,UAAkB;IACnC,OAAO,UAAU,IAAI,GAAG,IAAI,UAAU,IAAI,GAAG,CAAC;AAChD,CAAC;AAFD,gBAEC;AAEM,KAAK,UAAU,cAAc,CAClC,QAAyB,EACzB,OAAoB;IAEpB,MAAM,MAAM,GAAc;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM;QAC3B,QAAQ;KACT,CAAC;IAEF,OAAO,MAAM,IAAA,gBAAO,EAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACvC,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC5B,OAAO,EAAE;YACP,aAAa,EAAE,SAAS,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YA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AK,CAAC,GAAG,IAAI,CAAC;QAC9B,KAAK,IAAI,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAVD,oDAUC;AAED,SAAgB,mBAAmB;IACjC,IAAI,KAAK,GAAG,IAAA,aAAI,EAAC,IAAA,eAAM,EAAC,GAAG,iBAAO,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,IAAA,aAAI,EAAC,iDAAiD,CAAC,CAAC;IACtE,KAAK,IAAI,IAAA,gBAAM,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC;AACf,CAAC;AALD,kDAKC"}
|
package/dist/reporters/base.d.ts
CHANGED
|
@@ -23,14 +23,22 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
import SonicBoom from 'sonic-boom';
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
import { Reporter, ReporterOptions } from '.';
|
|
27
|
+
import { JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
28
|
+
import { Journey, Step } from '../dsl';
|
|
29
|
+
export default class BaseReporter implements Reporter {
|
|
30
30
|
stream: SonicBoom;
|
|
31
31
|
fd: number;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
metrics: {
|
|
33
|
+
succeeded: number;
|
|
34
|
+
failed: number;
|
|
35
|
+
skipped: number;
|
|
36
|
+
};
|
|
37
|
+
constructor(options?: ReporterOptions);
|
|
38
|
+
onJourneyStart(journey: Journey, {}: JourneyStartResult): void;
|
|
39
|
+
onStepEnd(journey: Journey, step: Step, result: StepEndResult): void;
|
|
40
|
+
onJourneyEnd(journey: Journey, { error }: JourneyEndResult): void;
|
|
41
|
+
onEnd(): void;
|
|
34
42
|
write(message: any): void;
|
|
35
43
|
}
|
|
36
44
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AASnC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAyBvC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IACnD,MAAM,EAAE,SAAS,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO;;;;MAIL;gBAEU,OAAO,GAAE,eAAoB;IAUzC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,kBAAkB;IAIvD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa;IAW7D,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,gBAAgB;IAY1D,KAAK;IAwBL,KAAK,CAAC,OAAO,KAAA;CAMd"}
|
package/dist/reporters/base.js
CHANGED
|
@@ -52,8 +52,12 @@ function renderDuration(durationMs) {
|
|
|
52
52
|
return parseInt(durationMs);
|
|
53
53
|
}
|
|
54
54
|
class BaseReporter {
|
|
55
|
-
constructor(
|
|
56
|
-
this.
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this.metrics = {
|
|
57
|
+
succeeded: 0,
|
|
58
|
+
failed: 0,
|
|
59
|
+
skipped: 0,
|
|
60
|
+
};
|
|
57
61
|
this.fd = options.fd || process.stdout.fd;
|
|
58
62
|
/**
|
|
59
63
|
* minLength is set to 1 byte to make sure we flush the
|
|
@@ -61,54 +65,48 @@ class BaseReporter {
|
|
|
61
65
|
* before destroying the pipe with underlying file descriptor
|
|
62
66
|
*/
|
|
63
67
|
this.stream = new sonic_boom_1.default({ fd: this.fd, sync: true, minLength: 1 });
|
|
64
|
-
// flushSync is used here to make sure all the data from the underlying
|
|
65
|
-
// SonicBoom stream buffer is completely written to the fd before closing
|
|
66
|
-
// the process
|
|
67
|
-
this.runner.on('end', () => this.stream.flushSync());
|
|
68
|
-
this._registerListeners();
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const total = failed + succeeded + skipped;
|
|
99
|
-
let message = '\n';
|
|
100
|
-
if (total === 0) {
|
|
101
|
-
message = 'No tests found!';
|
|
102
|
-
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
103
|
-
this.write(message);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
message += succeeded > 0 ? (0, colors_1.green)(` ${succeeded} passed`) : '';
|
|
107
|
-
message += failed > 0 ? (0, colors_1.red)(` ${failed} failed`) : '';
|
|
108
|
-
message += skipped > 0 ? (0, colors_1.cyan)(` ${skipped} skipped`) : '';
|
|
69
|
+
onJourneyStart(journey, {}) {
|
|
70
|
+
this.write(`\nJourney: ${journey.name}`);
|
|
71
|
+
}
|
|
72
|
+
onStepEnd(journey, step, result) {
|
|
73
|
+
const { status, end, start, error } = result;
|
|
74
|
+
const message = `${helpers_1.symbols[status]} Step: '${step.name}' ${status} (${renderDuration((end - start) * 1000)} ms)`;
|
|
75
|
+
this.write((0, helpers_1.indent)(message));
|
|
76
|
+
error && this.write(renderError(error));
|
|
77
|
+
this.metrics[status]++;
|
|
78
|
+
}
|
|
79
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
80
|
+
onJourneyEnd(journey, { error }) {
|
|
81
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
82
|
+
const total = failed + succeeded + skipped;
|
|
83
|
+
/**
|
|
84
|
+
* Render the error on the terminal only when no steps could
|
|
85
|
+
* be executed which means the error happened in one of the hooks
|
|
86
|
+
*/
|
|
87
|
+
if (total === 0 && error) {
|
|
88
|
+
this.write(renderError(error));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onEnd() {
|
|
92
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
93
|
+
const total = failed + succeeded + skipped;
|
|
94
|
+
let message = '\n';
|
|
95
|
+
if (total === 0) {
|
|
96
|
+
message = 'No tests found!';
|
|
109
97
|
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
110
98
|
this.write(message);
|
|
111
|
-
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
message += succeeded > 0 ? (0, colors_1.green)(` ${succeeded} passed`) : '';
|
|
102
|
+
message += failed > 0 ? (0, colors_1.red)(` ${failed} failed`) : '';
|
|
103
|
+
message += skipped > 0 ? (0, colors_1.cyan)(` ${skipped} skipped`) : '';
|
|
104
|
+
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
105
|
+
this.write(message);
|
|
106
|
+
// flushSync is used here to make sure all the data from the underlying
|
|
107
|
+
// SonicBoom stream buffer is completely written to the fd before closing
|
|
108
|
+
// the process
|
|
109
|
+
this.stream.flushSync();
|
|
112
110
|
}
|
|
113
111
|
write(message) {
|
|
114
112
|
if (typeof message == 'object') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AAEH,4DAAmC;AACnC,yCAAgD;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AAEH,4DAAmC;AACnC,yCAAgD;AAChD,wCAMoB;AASpB,SAAS,WAAW,CAAC,KAAK;IACxB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,EAAE,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,MAAM,IAAI,SAAS,CAAC;IACpB,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IACxB,IAAI,KAAK,EAAE;QACT,MAAM,IAAI,KAAK,GAAG,aAAa,CAAC;QAChC,KAAK,GAAG,IAAA,2BAAiB,EAAC,KAAK,EAAE,IAAA,2BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;SACtC;KACF;IACD,MAAM,IAAI,SAAS,CAAC;IACpB,OAAO,IAAA,YAAG,EAAC,MAAM,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,cAAc,CAAC,UAAU;IAChC,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAED,MAAqB,YAAY;IAS/B,YAAY,UAA2B,EAAE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AAC,SAAS,CAAC,OAAO,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AA5ED,+BA4EC"}
|
|
@@ -22,14 +22,24 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
import { Journey, Step } from '../dsl';
|
|
26
|
+
import { StartEvent, JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
27
|
+
export declare type ReporterOptions = {
|
|
28
|
+
fd?: number;
|
|
29
|
+
colors?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare type BuiltInReporterName = 'default' | 'json' | 'junit';
|
|
32
|
+
export declare type ReporterInstance = new (opts: ReporterOptions) => Reporter;
|
|
30
33
|
export declare const reporters: {
|
|
31
|
-
|
|
32
|
-
json: typeof JSONReporter;
|
|
33
|
-
junit: typeof JUnitReporter;
|
|
34
|
+
[key in BuiltInReporterName]: ReporterInstance;
|
|
34
35
|
};
|
|
36
|
+
export interface Reporter {
|
|
37
|
+
onStart?(params: StartEvent): void;
|
|
38
|
+
onJourneyRegister?(journey: Journey): void;
|
|
39
|
+
onJourneyStart?(journey: Journey, result: JourneyStartResult): void;
|
|
40
|
+
onStepStart?(journey: Journey, step: Step): void;
|
|
41
|
+
onStepEnd?(journey: Journey, step: Step, result: StepEndResult): void;
|
|
42
|
+
onJourneyEnd?(journey: Journey, result: JourneyEndResult): void | Promise<void>;
|
|
43
|
+
onEnd?(): void | Promise<void>;
|
|
44
|
+
}
|
|
35
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|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@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;AAYvB,QAAA,SAAS,GAElB;IACF,OAAO,EAAE,cAAY;IACrB,IAAI,EAAE,cAAY;IAClB,KAAK,EAAE,eAAa;CACrB,CAAC"}
|
package/dist/reporters/json.d.ts
CHANGED
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
/// <reference types="node" />
|
|
26
26
|
import BaseReporter from './base';
|
|
27
27
|
import { Journey, Step } from '../dsl';
|
|
28
|
-
import { NetworkInfo, NetworkConditions, TraceOutput, StatusValue, PerfMetrics, Params, Screenshot } from '../common_types';
|
|
29
|
-
import { PageMetrics } from '../plugins';
|
|
28
|
+
import { NetworkInfo, NetworkConditions, TraceOutput, StatusValue, PerfMetrics, Params, Screenshot, StartEvent, JourneyStartResult, StepEndResult, JourneyEndResult, PageMetrics } from '../common_types';
|
|
30
29
|
declare type OutputType = 'synthetics/metadata' | 'journey/register' | 'journey/start' | 'screenshot/block' | 'step/screenshot_ref' | 'step/screenshot' | 'step/metrics' | 'step/filmstrips' | 'step/end' | 'journey/network_info' | 'journey/browserconsole' | 'journey/end';
|
|
31
30
|
declare type Payload = {
|
|
32
31
|
source?: string;
|
|
@@ -116,7 +115,12 @@ export declare function getScreenshotBlocks(screenshot: Buffer): Promise<{
|
|
|
116
115
|
*/
|
|
117
116
|
export declare function gatherScreenshots(screenshotsPath: string, callback: (data: Screenshot) => Promise<void>): Promise<void>;
|
|
118
117
|
export default class JSONReporter extends BaseReporter {
|
|
119
|
-
|
|
118
|
+
onStart(params: StartEvent): void;
|
|
119
|
+
onJourneyRegister(journey: Journey): void;
|
|
120
|
+
onJourneyStart(journey: Journey, { timestamp, params }: JourneyStartResult): void;
|
|
121
|
+
onStepEnd(journey: Journey, step: Step, { start, end, error, url, status, pagemetrics, traces, metrics, filmstrips, }: StepEndResult): void;
|
|
122
|
+
onJourneyEnd(journey: Journey, { timestamp, start, end, networkinfo, browserconsole, status, error, options, }: JourneyEndResult): Promise<void>;
|
|
123
|
+
onEnd(): void;
|
|
120
124
|
writeScreenshotBlocks(journey: Journey, screenshot: Screenshot): Promise<void>;
|
|
121
125
|
writeMetrics(journey: Journey, step: Step, type: string, events: Array<TraceOutput> | PerfMetrics): void;
|
|
122
126
|
writeJSON({ _id, journey, type, timestamp, step, root_fields, error, payload, blob, blob_mime, url, }: OutputFields): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,MAAM,EACN,UAAU,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACZ,MAAM,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EAAE,UAAU,EAAE,UAAU;IAyBpE,YAAY,CACV,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,WAAW;IAuB1C,SAAS,CAAC,EACR,GAAG,EACH,OAAO,EACP,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,WAAW,EACX,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,GACJ,EAAE,YAAY;CAgBhB"}
|
package/dist/reporters/json.js
CHANGED
|
@@ -198,143 +198,143 @@ async function gatherScreenshots(screenshotsPath, callback) {
|
|
|
198
198
|
}
|
|
199
199
|
exports.gatherScreenshots = gatherScreenshots;
|
|
200
200
|
class JSONReporter extends base_1.default {
|
|
201
|
-
|
|
201
|
+
onStart(params) {
|
|
202
202
|
/**
|
|
203
203
|
* report the number of journeys that exists on a suite which
|
|
204
204
|
* could be used for better sharding
|
|
205
205
|
*/
|
|
206
|
-
this.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
: undefined,
|
|
217
|
-
});
|
|
206
|
+
this.writeJSON({
|
|
207
|
+
type: 'synthetics/metadata',
|
|
208
|
+
root_fields: {
|
|
209
|
+
num_journeys: params.numJourneys,
|
|
210
|
+
},
|
|
211
|
+
payload: params.networkConditions
|
|
212
|
+
? {
|
|
213
|
+
network_conditions: params.networkConditions,
|
|
214
|
+
}
|
|
215
|
+
: undefined,
|
|
218
216
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
217
|
+
}
|
|
218
|
+
onJourneyRegister(journey) {
|
|
219
|
+
this.writeJSON({
|
|
220
|
+
type: 'journey/register',
|
|
221
|
+
journey,
|
|
224
222
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
223
|
+
}
|
|
224
|
+
onJourneyStart(journey, { timestamp, params }) {
|
|
225
|
+
this.writeJSON({
|
|
226
|
+
type: 'journey/start',
|
|
227
|
+
journey,
|
|
228
|
+
timestamp,
|
|
229
|
+
payload: { params, source: journey.callback.toString() },
|
|
232
230
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
},
|
|
247
|
-
blob: strip.blob,
|
|
248
|
-
blob_mime: strip.mime,
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
this.writeJSON({
|
|
253
|
-
type: 'step/end',
|
|
254
|
-
journey,
|
|
255
|
-
step: {
|
|
256
|
-
...step,
|
|
257
|
-
duration: {
|
|
258
|
-
us: (0, helpers_1.getDurationInUs)(end - start),
|
|
231
|
+
}
|
|
232
|
+
onStepEnd(journey, step, { start, end, error, url, status, pagemetrics, traces, metrics, filmstrips, }) {
|
|
233
|
+
this.writeMetrics(journey, step, 'relative_trace', traces);
|
|
234
|
+
this.writeMetrics(journey, step, 'experience', metrics);
|
|
235
|
+
if (filmstrips) {
|
|
236
|
+
// Write each filmstrip separately so that we don't get documents that are too large
|
|
237
|
+
filmstrips.forEach((strip, index) => {
|
|
238
|
+
this.writeJSON({
|
|
239
|
+
type: 'step/filmstrips',
|
|
240
|
+
journey,
|
|
241
|
+
step,
|
|
242
|
+
payload: { index },
|
|
243
|
+
root_fields: {
|
|
244
|
+
browser: { relative_trace: { start: strip.start } },
|
|
259
245
|
},
|
|
246
|
+
blob: strip.blob,
|
|
247
|
+
blob_mime: strip.mime,
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
this.writeJSON({
|
|
252
|
+
type: 'step/end',
|
|
253
|
+
journey,
|
|
254
|
+
step: {
|
|
255
|
+
...step,
|
|
256
|
+
duration: {
|
|
257
|
+
us: (0, helpers_1.getDurationInUs)(end - start),
|
|
260
258
|
},
|
|
259
|
+
},
|
|
260
|
+
url,
|
|
261
|
+
error,
|
|
262
|
+
payload: {
|
|
263
|
+
source: step.callback.toString(),
|
|
261
264
|
url,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
url,
|
|
266
|
-
status,
|
|
267
|
-
pagemetrics,
|
|
268
|
-
},
|
|
269
|
-
});
|
|
265
|
+
status,
|
|
266
|
+
pagemetrics,
|
|
267
|
+
},
|
|
270
268
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
type: 'step/screenshot',
|
|
287
|
-
timestamp,
|
|
288
|
-
journey,
|
|
289
|
-
step,
|
|
290
|
-
blob: data,
|
|
291
|
-
blob_mime: 'image/jpeg',
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
if (networkinfo) {
|
|
297
|
-
networkinfo.forEach(ni => {
|
|
298
|
-
const { ecs, payload } = formatNetworkFields(ni);
|
|
299
|
-
this.writeJSON({
|
|
300
|
-
type: 'journey/network_info',
|
|
301
|
-
journey,
|
|
302
|
-
timestamp: ni.timestamp,
|
|
303
|
-
root_fields: (0, snakecase_keys_1.default)(ecs),
|
|
304
|
-
step: ni.step,
|
|
305
|
-
payload: (0, snakecase_keys_1.default)(payload),
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
if (browserconsole) {
|
|
310
|
-
browserconsole.forEach(({ timestamp, text, type, step, error }) => {
|
|
269
|
+
}
|
|
270
|
+
async onJourneyEnd(journey, { timestamp, start, end, networkinfo, browserconsole, status, error, options, }) {
|
|
271
|
+
const { ssblocks, screenshots } = options;
|
|
272
|
+
const writeScreenshots = screenshots === 'on' ||
|
|
273
|
+
(screenshots === 'only-on-failure' && status === 'failed');
|
|
274
|
+
if (writeScreenshots) {
|
|
275
|
+
await gatherScreenshots((0, path_1.join)(helpers_1.CACHE_PATH, 'screenshots'), async (screenshot) => {
|
|
276
|
+
const { data, timestamp, step } = screenshot;
|
|
277
|
+
if (!data) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (ssblocks) {
|
|
281
|
+
await this.writeScreenshotBlocks(journey, screenshot);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
311
284
|
this.writeJSON({
|
|
312
|
-
type: '
|
|
313
|
-
journey,
|
|
285
|
+
type: 'step/screenshot',
|
|
314
286
|
timestamp,
|
|
287
|
+
journey,
|
|
315
288
|
step,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
text,
|
|
319
|
-
type,
|
|
320
|
-
},
|
|
289
|
+
blob: data,
|
|
290
|
+
blob_mime: 'image/jpeg',
|
|
321
291
|
});
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
if (networkinfo) {
|
|
296
|
+
networkinfo.forEach(ni => {
|
|
297
|
+
const { ecs, payload } = formatNetworkFields(ni);
|
|
298
|
+
this.writeJSON({
|
|
299
|
+
type: 'journey/network_info',
|
|
300
|
+
journey,
|
|
301
|
+
timestamp: ni.timestamp,
|
|
302
|
+
root_fields: (0, snakecase_keys_1.default)(ecs),
|
|
303
|
+
step: ni.step,
|
|
304
|
+
payload: (0, snakecase_keys_1.default)(payload),
|
|
322
305
|
});
|
|
323
|
-
}
|
|
324
|
-
this.writeJSON({
|
|
325
|
-
type: 'journey/end',
|
|
326
|
-
journey,
|
|
327
|
-
timestamp,
|
|
328
|
-
error,
|
|
329
|
-
payload: {
|
|
330
|
-
start,
|
|
331
|
-
end,
|
|
332
|
-
status,
|
|
333
|
-
},
|
|
334
306
|
});
|
|
335
|
-
|
|
307
|
+
}
|
|
308
|
+
if (browserconsole) {
|
|
309
|
+
browserconsole.forEach(({ timestamp, text, type, step, error }) => {
|
|
310
|
+
this.writeJSON({
|
|
311
|
+
type: 'journey/browserconsole',
|
|
312
|
+
journey,
|
|
313
|
+
timestamp,
|
|
314
|
+
step,
|
|
315
|
+
error,
|
|
316
|
+
payload: {
|
|
317
|
+
text,
|
|
318
|
+
type,
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
this.writeJSON({
|
|
324
|
+
type: 'journey/end',
|
|
325
|
+
journey,
|
|
326
|
+
timestamp,
|
|
327
|
+
error,
|
|
328
|
+
payload: {
|
|
329
|
+
start,
|
|
330
|
+
end,
|
|
331
|
+
status,
|
|
332
|
+
},
|
|
336
333
|
});
|
|
337
334
|
}
|
|
335
|
+
onEnd() {
|
|
336
|
+
this.stream.flushSync();
|
|
337
|
+
}
|
|
338
338
|
async writeScreenshotBlocks(journey, screenshot) {
|
|
339
339
|
const { blob_mime, blocks, reference } = await getScreenshotBlocks(Buffer.from(screenshot.data, 'base64'));
|
|
340
340
|
for (let i = 0; i < blocks.length; i++) {
|