@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.30
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 +4 -3
- package/dist/cli.js +99 -162
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +156 -34
- 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 +5 -5
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.js +5 -5
- package/dist/core/browser-service.js.map +1 -1
- package/dist/core/gatherer.d.ts +4 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +46 -14
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -11
- 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 +3 -16
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +21 -65
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +211 -93
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +7 -3
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +22 -6
- package/dist/dsl/journey.js.map +1 -1
- package/{src/reporters/reporter.ts → dist/dsl/locations.d.ts} +12 -10
- package/dist/dsl/locations.d.ts.map +1 -0
- package/dist/dsl/locations.js +41 -0
- package/dist/dsl/locations.js.map +1 -0
- package/dist/dsl/monitor.d.ts +65 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +63 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/dsl/step.d.ts +3 -2
- package/dist/dsl/step.d.ts.map +1 -1
- package/dist/dsl/step.js +2 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +98 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +295 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +21 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +169 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → generator/utils.d.ts} +4 -9
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +57 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +20 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +98 -18
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +144 -0
- package/dist/loader.js.map +1 -0
- package/dist/options.d.ts +34 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +162 -0
- package/dist/options.js.map +1 -0
- package/dist/plugins/browser-console.d.ts +5 -4
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +27 -8
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/network.d.ts +20 -33
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +173 -214
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +4 -19
- 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 +9 -5
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +44 -29
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +6 -6
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +8 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +114 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +55 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +32 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +62 -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 +124 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +42 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +84 -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 +54 -48
- 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 +18 -67
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +153 -175
- 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 +94 -89
- package/dist/reporters/junit.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +35 -9
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
- package/dist/sdk/lh-trace-processor.js +114 -53
- package/dist/sdk/lh-trace-processor.js.map +1 -1
- package/dist/sdk/trace-metrics.d.ts +4 -4
- package/dist/sdk/trace-metrics.d.ts.map +1 -1
- package/dist/sdk/trace-metrics.js +5 -6
- package/dist/sdk/trace-metrics.js.map +1 -1
- package/dist/sdk/trace-processor.d.ts +11 -3
- package/dist/sdk/trace-processor.d.ts.map +1 -1
- package/dist/sdk/trace-processor.js +17 -9
- package/dist/sdk/trace-processor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1888
- package/package.json +31 -19
- package/src/cli.ts +187 -154
- package/src/common_types.ts +188 -34
- package/src/config.ts +2 -5
- package/src/core/gatherer.ts +55 -27
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +216 -152
- package/src/dsl/journey.ts +29 -5
- package/src/dsl/locations.ts +38 -0
- package/src/dsl/monitor.ts +87 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +367 -0
- package/src/generator/index.ts +212 -0
- package/src/generator/utils.ts +54 -0
- package/src/helpers.ts +106 -10
- package/src/index.ts +21 -22
- package/src/loader.ts +162 -0
- package/src/options.ts +173 -0
- package/src/plugins/browser-console.ts +30 -8
- package/src/plugins/network.ts +208 -267
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +8 -9
- package/src/push/bundler.ts +95 -0
- package/src/push/index.ts +59 -0
- package/src/push/monitor.ts +68 -0
- package/src/push/plugin.ts +114 -0
- package/src/push/request.ts +111 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +203 -206
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +10 -6
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +26 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/synthetics.config.ts +26 -0
- package/CHANGELOG.md +0 -102
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -89
- package/dist/parse_args.js.map +0 -1
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
- package/src/parse_args.ts +0 -127
package/src/reporters/base.ts
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
import SonicBoom from 'sonic-boom';
|
|
27
27
|
import { green, red, cyan } from 'kleur/colors';
|
|
28
|
-
import Runner from '../core/runner';
|
|
29
28
|
import {
|
|
30
29
|
symbols,
|
|
31
30
|
indent,
|
|
@@ -33,7 +32,13 @@ import {
|
|
|
33
32
|
findPWLogsIndexes,
|
|
34
33
|
rewriteErrorStack,
|
|
35
34
|
} from '../helpers';
|
|
36
|
-
import { ReporterOptions } from '
|
|
35
|
+
import { Reporter, ReporterOptions } from '.';
|
|
36
|
+
import {
|
|
37
|
+
JourneyEndResult,
|
|
38
|
+
JourneyStartResult,
|
|
39
|
+
StepEndResult,
|
|
40
|
+
} from '../common_types';
|
|
41
|
+
import { Journey, Step } from '../dsl';
|
|
37
42
|
|
|
38
43
|
function renderError(error) {
|
|
39
44
|
let output = '';
|
|
@@ -58,68 +63,74 @@ function renderDuration(durationMs) {
|
|
|
58
63
|
return parseInt(durationMs);
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
export default class BaseReporter {
|
|
66
|
+
export default class BaseReporter implements Reporter {
|
|
62
67
|
stream: SonicBoom;
|
|
63
68
|
fd: number;
|
|
69
|
+
metrics = {
|
|
70
|
+
succeeded: 0,
|
|
71
|
+
failed: 0,
|
|
72
|
+
skipped: 0,
|
|
73
|
+
};
|
|
64
74
|
|
|
65
|
-
constructor(
|
|
75
|
+
constructor(options: ReporterOptions = {}) {
|
|
66
76
|
this.fd = options.fd || process.stdout.fd;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
/**
|
|
78
|
+
* minLength is set to 1 byte to make sure we flush the
|
|
79
|
+
* content even if its the last byte on the stream buffer
|
|
80
|
+
* before destroying the pipe with underlying file descriptor
|
|
81
|
+
*/
|
|
82
|
+
this.stream = new SonicBoom({ fd: this.fd, sync: true, minLength: 1 });
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
failed: 0,
|
|
76
|
-
skipped: 0,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
this.runner.on('journey:start', ({ journey }) => {
|
|
80
|
-
this.write(`\nJourney: ${journey.name}`);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
this.runner.on('step:end', ({ step, start, end, error, status }) => {
|
|
84
|
-
const message = `${symbols[status]} Step: '${
|
|
85
|
-
step.name
|
|
86
|
-
}' ${status} (${renderDuration((end - start) * 1000)} ms)`;
|
|
87
|
-
this.write(indent(message));
|
|
88
|
-
error && this.write(renderError(error));
|
|
89
|
-
result[status]++;
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
this.runner.on('journey:end', ({ error }) => {
|
|
93
|
-
const { failed, succeeded, skipped } = result;
|
|
94
|
-
const total = failed + succeeded + skipped;
|
|
85
|
+
onJourneyStart(journey: Journey, {}: JourneyStartResult) {
|
|
86
|
+
this.write(`\nJourney: ${journey.name}`);
|
|
87
|
+
}
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
onStepEnd(journey: Journey, step: Step, result: StepEndResult) {
|
|
90
|
+
const { status, end, start, error } = result;
|
|
91
|
+
const message = `${symbols[status]} Step: '${
|
|
92
|
+
step.name
|
|
93
|
+
}' ${status} (${renderDuration((end - start) * 1000)} ms)`;
|
|
94
|
+
this.write(indent(message));
|
|
95
|
+
error && this.write(renderError(error));
|
|
96
|
+
this.metrics[status]++;
|
|
97
|
+
}
|
|
104
98
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
100
|
+
onJourneyEnd(journey: Journey, { error }: JourneyEndResult) {
|
|
101
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
102
|
+
const total = failed + succeeded + skipped;
|
|
103
|
+
/**
|
|
104
|
+
* Render the error on the terminal only when no steps could
|
|
105
|
+
* be executed which means the error happened in one of the hooks
|
|
106
|
+
*/
|
|
107
|
+
if (total === 0 && error) {
|
|
108
|
+
this.write(renderError(error));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
message += ` (${renderDuration(now())} ms) \n`;
|
|
113
|
-
this.write(message);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
112
|
+
onEnd() {
|
|
113
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
114
|
+
const total = failed + succeeded + skipped;
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
message
|
|
116
|
+
let message = '\n';
|
|
117
|
+
if (total === 0) {
|
|
118
|
+
message = 'No tests found!';
|
|
120
119
|
message += ` (${renderDuration(now())} ms) \n`;
|
|
121
120
|
this.write(message);
|
|
122
|
-
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
message += succeeded > 0 ? green(` ${succeeded} passed`) : '';
|
|
125
|
+
message += failed > 0 ? red(` ${failed} failed`) : '';
|
|
126
|
+
message += skipped > 0 ? cyan(` ${skipped} skipped`) : '';
|
|
127
|
+
message += ` (${renderDuration(now())} ms) \n`;
|
|
128
|
+
this.write(message);
|
|
129
|
+
|
|
130
|
+
// flushSync is used here to make sure all the data from the underlying
|
|
131
|
+
// SonicBoom stream buffer is completely written to the fd before closing
|
|
132
|
+
// the process
|
|
133
|
+
this.stream.flushSync();
|
|
123
134
|
}
|
|
124
135
|
|
|
125
136
|
write(message) {
|
package/src/reporters/index.ts
CHANGED
|
@@ -26,11 +26,34 @@
|
|
|
26
26
|
import BaseReporter from './base';
|
|
27
27
|
import JSONReporter from './json';
|
|
28
28
|
import JUnitReporter from './junit';
|
|
29
|
-
import
|
|
29
|
+
import { Journey, Step } from '../dsl';
|
|
30
|
+
import {
|
|
31
|
+
StartEvent,
|
|
32
|
+
JourneyEndResult,
|
|
33
|
+
JourneyStartResult,
|
|
34
|
+
StepEndResult,
|
|
35
|
+
} from '../common_types';
|
|
30
36
|
|
|
31
|
-
export {
|
|
32
|
-
export
|
|
37
|
+
export type ReporterOptions = { fd?: number; colors?: boolean };
|
|
38
|
+
export type BuiltInReporterName = 'default' | 'json' | 'junit';
|
|
39
|
+
export type ReporterInstance = new (opts: ReporterOptions) => Reporter;
|
|
40
|
+
export const reporters: {
|
|
41
|
+
[key in BuiltInReporterName]: ReporterInstance;
|
|
42
|
+
} = {
|
|
33
43
|
default: BaseReporter,
|
|
34
44
|
json: JSONReporter,
|
|
35
45
|
junit: JUnitReporter,
|
|
36
46
|
};
|
|
47
|
+
|
|
48
|
+
export interface Reporter {
|
|
49
|
+
onStart?(params: StartEvent): void;
|
|
50
|
+
onJourneyRegister?(journey: Journey): void;
|
|
51
|
+
onJourneyStart?(journey: Journey, result: JourneyStartResult): void;
|
|
52
|
+
onStepStart?(journey: Journey, step: Step): void;
|
|
53
|
+
onStepEnd?(journey: Journey, step: Step, result: StepEndResult): void;
|
|
54
|
+
onJourneyEnd?(
|
|
55
|
+
journey: Journey,
|
|
56
|
+
result: JourneyEndResult
|
|
57
|
+
): void | Promise<void>;
|
|
58
|
+
onEnd?(): void | Promise<void>;
|
|
59
|
+
}
|