@elastic/synthetics 1.0.0-beta.14 → 1.0.0-beta.18
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 +61 -0
- package/README.md +1 -0
- package/dist/cli.js +37 -21
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +13 -4
- package/dist/common_types.d.ts.map +1 -1
- package/dist/core/gatherer.d.ts +3 -1
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +29 -3
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/runner.d.ts +23 -22
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +22 -9
- package/dist/core/runner.js.map +1 -1
- package/dist/formatter/javascript.d.ts +1 -0
- package/dist/formatter/javascript.d.ts.map +1 -1
- package/dist/formatter/javascript.js +8 -3
- package/dist/formatter/javascript.js.map +1 -1
- package/dist/helpers.d.ts +7 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +50 -2
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/parse_args.d.ts.map +1 -1
- package/dist/parse_args.js +5 -1
- package/dist/parse_args.js.map +1 -1
- package/dist/plugins/network.d.ts +1 -5
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/reporters/json.d.ts +4 -3
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +19 -9
- package/dist/reporters/json.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/cli.ts +42 -25
- package/src/common_types.ts +14 -4
- package/src/core/gatherer.ts +39 -4
- package/src/core/runner.ts +57 -34
- package/src/formatter/javascript.ts +9 -3
- package/src/helpers.ts +60 -2
- package/src/index.ts +1 -0
- package/src/parse_args.ts +10 -5
- package/src/reporters/json.ts +23 -16
package/src/reporters/json.ts
CHANGED
|
@@ -40,10 +40,12 @@ import { Journey, Step } from '../dsl';
|
|
|
40
40
|
import snakeCaseKeys from 'snakecase-keys';
|
|
41
41
|
import {
|
|
42
42
|
NetworkInfo,
|
|
43
|
+
NetworkConditions,
|
|
43
44
|
TraceOutput,
|
|
44
45
|
StatusValue,
|
|
45
46
|
PerfMetrics,
|
|
46
47
|
Params,
|
|
48
|
+
Screenshot,
|
|
47
49
|
} from '../common_types';
|
|
48
50
|
import { Protocol } from 'playwright-chromium/types/protocol';
|
|
49
51
|
import { PageMetrics } from '../plugins';
|
|
@@ -76,6 +78,7 @@ type Payload = {
|
|
|
76
78
|
type?: OutputType;
|
|
77
79
|
text?: string;
|
|
78
80
|
index?: number;
|
|
81
|
+
network_conditions?: NetworkConditions;
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
type OutputFields = {
|
|
@@ -113,13 +116,6 @@ type ScreenshotReference = {
|
|
|
113
116
|
}>;
|
|
114
117
|
};
|
|
115
118
|
|
|
116
|
-
type ScreenshotOutput = {
|
|
117
|
-
step: Step;
|
|
118
|
-
blob_mime: string;
|
|
119
|
-
blocks: Array<ScreenshotBlob>;
|
|
120
|
-
reference: ScreenshotReference;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
119
|
function getMetadata() {
|
|
124
120
|
return {
|
|
125
121
|
os: {
|
|
@@ -331,14 +327,14 @@ export async function getScreenshotBlocks(screenshot: Buffer) {
|
|
|
331
327
|
*/
|
|
332
328
|
export async function gatherScreenshots(
|
|
333
329
|
screenshotsPath: string,
|
|
334
|
-
callback: (
|
|
330
|
+
callback: (data: Screenshot) => Promise<void>
|
|
335
331
|
) {
|
|
336
332
|
if (isDirectory(screenshotsPath)) {
|
|
337
333
|
await totalist(screenshotsPath, async (_, absPath) => {
|
|
338
334
|
try {
|
|
339
335
|
const content = readFileSync(absPath, 'utf8');
|
|
340
|
-
const
|
|
341
|
-
await callback(
|
|
336
|
+
const screenshot: Screenshot = JSON.parse(content);
|
|
337
|
+
await callback(screenshot);
|
|
342
338
|
} catch (_) {
|
|
343
339
|
// TODO: capture progarammatic synthetic errors under different type
|
|
344
340
|
}
|
|
@@ -352,12 +348,17 @@ export default class JSONReporter extends BaseReporter {
|
|
|
352
348
|
* report the number of journeys that exists on a suite which
|
|
353
349
|
* could be used for better sharding
|
|
354
350
|
*/
|
|
355
|
-
this.runner.on('start', ({ numJourneys }) => {
|
|
351
|
+
this.runner.on('start', ({ numJourneys, networkConditions }) => {
|
|
356
352
|
this.writeJSON({
|
|
357
353
|
type: 'synthetics/metadata',
|
|
358
354
|
root_fields: {
|
|
359
355
|
num_journeys: numJourneys,
|
|
360
356
|
},
|
|
357
|
+
payload: networkConditions
|
|
358
|
+
? {
|
|
359
|
+
network_conditions: networkConditions,
|
|
360
|
+
}
|
|
361
|
+
: undefined,
|
|
361
362
|
});
|
|
362
363
|
});
|
|
363
364
|
|
|
@@ -435,6 +436,7 @@ export default class JSONReporter extends BaseReporter {
|
|
|
435
436
|
'journey:end',
|
|
436
437
|
async ({
|
|
437
438
|
journey,
|
|
439
|
+
timestamp,
|
|
438
440
|
start,
|
|
439
441
|
end,
|
|
440
442
|
networkinfo,
|
|
@@ -450,15 +452,17 @@ export default class JSONReporter extends BaseReporter {
|
|
|
450
452
|
if (writeScreenshots) {
|
|
451
453
|
await gatherScreenshots(
|
|
452
454
|
join(CACHE_PATH, 'screenshots'),
|
|
453
|
-
async
|
|
455
|
+
async screenshot => {
|
|
456
|
+
const { data, timestamp, step } = screenshot;
|
|
454
457
|
if (!data) {
|
|
455
458
|
return;
|
|
456
459
|
}
|
|
457
460
|
if (ssblocks) {
|
|
458
|
-
await this.writeScreenshotBlocks(journey,
|
|
461
|
+
await this.writeScreenshotBlocks(journey, screenshot);
|
|
459
462
|
} else {
|
|
460
463
|
this.writeJSON({
|
|
461
464
|
type: 'step/screenshot',
|
|
465
|
+
timestamp,
|
|
462
466
|
journey,
|
|
463
467
|
step,
|
|
464
468
|
blob: data,
|
|
@@ -501,6 +505,7 @@ export default class JSONReporter extends BaseReporter {
|
|
|
501
505
|
this.writeJSON({
|
|
502
506
|
type: 'journey/end',
|
|
503
507
|
journey,
|
|
508
|
+
timestamp,
|
|
504
509
|
error,
|
|
505
510
|
payload: {
|
|
506
511
|
start,
|
|
@@ -513,14 +518,15 @@ export default class JSONReporter extends BaseReporter {
|
|
|
513
518
|
);
|
|
514
519
|
}
|
|
515
520
|
|
|
516
|
-
async writeScreenshotBlocks(journey: Journey,
|
|
521
|
+
async writeScreenshotBlocks(journey: Journey, screenshot: Screenshot) {
|
|
517
522
|
const { blob_mime, blocks, reference } = await getScreenshotBlocks(
|
|
518
|
-
Buffer.from(data, 'base64')
|
|
523
|
+
Buffer.from(screenshot.data, 'base64')
|
|
519
524
|
);
|
|
520
525
|
for (let i = 0; i < blocks.length; i++) {
|
|
521
526
|
const block = blocks[i];
|
|
522
527
|
this.writeJSON({
|
|
523
528
|
type: 'screenshot/block',
|
|
529
|
+
timestamp: screenshot.timestamp,
|
|
524
530
|
_id: block.id,
|
|
525
531
|
blob: block.blob,
|
|
526
532
|
blob_mime,
|
|
@@ -528,8 +534,9 @@ export default class JSONReporter extends BaseReporter {
|
|
|
528
534
|
}
|
|
529
535
|
this.writeJSON({
|
|
530
536
|
type: 'step/screenshot_ref',
|
|
537
|
+
timestamp: screenshot.timestamp,
|
|
531
538
|
journey,
|
|
532
|
-
step,
|
|
539
|
+
step: screenshot.step,
|
|
533
540
|
root_fields: {
|
|
534
541
|
screenshot_ref: reference,
|
|
535
542
|
},
|