@elastic/synthetics 1.0.0-beta.23 → 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 +62 -14
- 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 +14 -5
- 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 +89 -50
- 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/formatter/javascript.d.ts +1 -1
- package/dist/formatter/javascript.d.ts.map +1 -1
- package/dist/formatter/javascript.js +1 -1
- package/dist/formatter/javascript.js.map +1 -1
- 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 +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- 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/network.d.ts +17 -30
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +179 -244
- package/dist/plugins/network.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 +2 -2
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +2 -2
- package/dist/plugins/plugin-manager.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 +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 -4
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +119 -137
- 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 +14 -9
- package/src/cli.ts +65 -9
- package/src/common_types.ts +72 -14
- package/src/core/gatherer.ts +18 -10
- package/src/core/index.ts +15 -0
- package/src/core/runner.ts +87 -114
- package/src/dsl/journey.ts +18 -0
- package/src/dsl/monitor.ts +83 -0
- package/src/formatter/javascript.ts +1 -1
- package/src/generator/index.ts +159 -0
- package/src/generator/utils.ts +41 -0
- package/src/helpers.ts +36 -52
- package/src/index.ts +10 -2
- package/src/loader.ts +4 -4
- package/src/options.ts +71 -8
- package/src/plugins/network.ts +218 -293
- package/src/plugins/performance.ts +1 -17
- package/src/plugins/plugin-manager.ts +2 -2
- 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 +154 -162
- 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 -339
- package/NOTICE.txt +0 -250
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
package/src/reporters/json.ts
CHANGED
|
@@ -47,8 +47,12 @@ import {
|
|
|
47
47
|
PerfMetrics,
|
|
48
48
|
Params,
|
|
49
49
|
Screenshot,
|
|
50
|
+
StartEvent,
|
|
51
|
+
JourneyStartResult,
|
|
52
|
+
StepEndResult,
|
|
53
|
+
JourneyEndResult,
|
|
54
|
+
PageMetrics,
|
|
50
55
|
} from '../common_types';
|
|
51
|
-
import { PageMetrics } from '../plugins';
|
|
52
56
|
|
|
53
57
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
54
58
|
const { version, name } = require('../../package.json');
|
|
@@ -128,23 +132,8 @@ function getMetadata() {
|
|
|
128
132
|
};
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
function formatVersion(protocol: string | undefined) {
|
|
132
|
-
if (!protocol) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (protocol === 'h2') {
|
|
136
|
-
return 2;
|
|
137
|
-
} else if (protocol === 'http/1.1') {
|
|
138
|
-
return 1.1;
|
|
139
|
-
} else if (protocol === 'http/1.0') {
|
|
140
|
-
return 1.0;
|
|
141
|
-
} else if (protocol.startsWith('h3')) {
|
|
142
|
-
return 3;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
135
|
function formatTLS(tls: SecurityDetails) {
|
|
147
|
-
if (!tls) {
|
|
136
|
+
if (!tls || !tls.protocol) {
|
|
148
137
|
return;
|
|
149
138
|
}
|
|
150
139
|
const [name, version] = tls.protocol.toLowerCase().split(' ');
|
|
@@ -177,7 +166,6 @@ export function formatNetworkFields(network: NetworkInfo) {
|
|
|
177
166
|
original: request.headers?.['User-Agent'],
|
|
178
167
|
},
|
|
179
168
|
http: {
|
|
180
|
-
version: formatVersion(response?.protocol),
|
|
181
169
|
request,
|
|
182
170
|
response,
|
|
183
171
|
},
|
|
@@ -312,179 +300,183 @@ export async function gatherScreenshots(
|
|
|
312
300
|
}
|
|
313
301
|
|
|
314
302
|
export default class JSONReporter extends BaseReporter {
|
|
315
|
-
|
|
303
|
+
onStart(params: StartEvent) {
|
|
316
304
|
/**
|
|
317
305
|
* report the number of journeys that exists on a suite which
|
|
318
306
|
* could be used for better sharding
|
|
319
307
|
*/
|
|
320
|
-
this.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
: undefined,
|
|
331
|
-
});
|
|
308
|
+
this.writeJSON({
|
|
309
|
+
type: 'synthetics/metadata',
|
|
310
|
+
root_fields: {
|
|
311
|
+
num_journeys: params.numJourneys,
|
|
312
|
+
},
|
|
313
|
+
payload: params.networkConditions
|
|
314
|
+
? {
|
|
315
|
+
network_conditions: params.networkConditions,
|
|
316
|
+
}
|
|
317
|
+
: undefined,
|
|
332
318
|
});
|
|
319
|
+
}
|
|
333
320
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
});
|
|
321
|
+
onJourneyRegister(journey: Journey): void {
|
|
322
|
+
this.writeJSON({
|
|
323
|
+
type: 'journey/register',
|
|
324
|
+
journey,
|
|
339
325
|
});
|
|
326
|
+
}
|
|
340
327
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
328
|
+
override onJourneyStart(
|
|
329
|
+
journey: Journey,
|
|
330
|
+
{ timestamp, params }: JourneyStartResult
|
|
331
|
+
) {
|
|
332
|
+
this.writeJSON({
|
|
333
|
+
type: 'journey/start',
|
|
334
|
+
journey,
|
|
335
|
+
timestamp,
|
|
336
|
+
payload: { params, source: journey.callback.toString() },
|
|
348
337
|
});
|
|
338
|
+
}
|
|
349
339
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
this.writeJSON({
|
|
371
|
-
type: 'step/filmstrips',
|
|
372
|
-
journey,
|
|
373
|
-
step,
|
|
374
|
-
payload: { index },
|
|
375
|
-
root_fields: {
|
|
376
|
-
browser: { relative_trace: { start: strip.start } },
|
|
377
|
-
},
|
|
378
|
-
blob: strip.blob,
|
|
379
|
-
blob_mime: strip.mime,
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
}
|
|
340
|
+
override onStepEnd(
|
|
341
|
+
journey: Journey,
|
|
342
|
+
step: Step,
|
|
343
|
+
{
|
|
344
|
+
start,
|
|
345
|
+
end,
|
|
346
|
+
error,
|
|
347
|
+
url,
|
|
348
|
+
status,
|
|
349
|
+
pagemetrics,
|
|
350
|
+
traces,
|
|
351
|
+
metrics,
|
|
352
|
+
filmstrips,
|
|
353
|
+
}: StepEndResult
|
|
354
|
+
) {
|
|
355
|
+
this.writeMetrics(journey, step, 'relative_trace', traces);
|
|
356
|
+
this.writeMetrics(journey, step, 'experience', metrics);
|
|
357
|
+
if (filmstrips) {
|
|
358
|
+
// Write each filmstrip separately so that we don't get documents that are too large
|
|
359
|
+
filmstrips.forEach((strip, index) => {
|
|
383
360
|
this.writeJSON({
|
|
384
|
-
type: 'step/
|
|
361
|
+
type: 'step/filmstrips',
|
|
385
362
|
journey,
|
|
386
|
-
step
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
url,
|
|
393
|
-
error,
|
|
394
|
-
payload: {
|
|
395
|
-
source: step.callback.toString(),
|
|
396
|
-
url,
|
|
397
|
-
status,
|
|
398
|
-
pagemetrics,
|
|
363
|
+
step,
|
|
364
|
+
payload: { index },
|
|
365
|
+
root_fields: {
|
|
366
|
+
browser: { relative_trace: { start: strip.start } },
|
|
399
367
|
},
|
|
368
|
+
blob: strip.blob,
|
|
369
|
+
blob_mime: strip.mime,
|
|
400
370
|
});
|
|
401
|
-
}
|
|
402
|
-
|
|
371
|
+
});
|
|
372
|
+
}
|
|
403
373
|
|
|
404
|
-
this.
|
|
405
|
-
'
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
374
|
+
this.writeJSON({
|
|
375
|
+
type: 'step/end',
|
|
376
|
+
journey,
|
|
377
|
+
step: {
|
|
378
|
+
...step,
|
|
379
|
+
duration: {
|
|
380
|
+
us: getDurationInUs(end - start),
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
url,
|
|
384
|
+
error,
|
|
385
|
+
payload: {
|
|
386
|
+
source: step.callback.toString(),
|
|
387
|
+
url,
|
|
413
388
|
status,
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const writeScreenshots =
|
|
419
|
-
screenshots === 'on' ||
|
|
420
|
-
(screenshots === 'only-on-failure' && status === 'failed');
|
|
421
|
-
if (writeScreenshots) {
|
|
422
|
-
await gatherScreenshots(
|
|
423
|
-
join(CACHE_PATH, 'screenshots'),
|
|
424
|
-
async screenshot => {
|
|
425
|
-
const { data, timestamp, step } = screenshot;
|
|
426
|
-
if (!data) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
if (ssblocks) {
|
|
430
|
-
await this.writeScreenshotBlocks(journey, screenshot);
|
|
431
|
-
} else {
|
|
432
|
-
this.writeJSON({
|
|
433
|
-
type: 'step/screenshot',
|
|
434
|
-
timestamp,
|
|
435
|
-
journey,
|
|
436
|
-
step,
|
|
437
|
-
blob: data,
|
|
438
|
-
blob_mime: 'image/jpeg',
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
);
|
|
443
|
-
}
|
|
389
|
+
pagemetrics,
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
}
|
|
444
393
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
394
|
+
override async onJourneyEnd(
|
|
395
|
+
journey: Journey,
|
|
396
|
+
{
|
|
397
|
+
timestamp,
|
|
398
|
+
start,
|
|
399
|
+
end,
|
|
400
|
+
networkinfo,
|
|
401
|
+
browserconsole,
|
|
402
|
+
status,
|
|
403
|
+
error,
|
|
404
|
+
options,
|
|
405
|
+
}: JourneyEndResult
|
|
406
|
+
) {
|
|
407
|
+
const { ssblocks, screenshots } = options;
|
|
408
|
+
const writeScreenshots =
|
|
409
|
+
screenshots === 'on' ||
|
|
410
|
+
(screenshots === 'only-on-failure' && status === 'failed');
|
|
411
|
+
if (writeScreenshots) {
|
|
412
|
+
await gatherScreenshots(
|
|
413
|
+
join(CACHE_PATH, 'screenshots'),
|
|
414
|
+
async screenshot => {
|
|
415
|
+
const { data, timestamp, step } = screenshot;
|
|
416
|
+
if (!data) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
if (ssblocks) {
|
|
420
|
+
await this.writeScreenshotBlocks(journey, screenshot);
|
|
421
|
+
} else {
|
|
460
422
|
this.writeJSON({
|
|
461
|
-
type: '
|
|
462
|
-
journey,
|
|
423
|
+
type: 'step/screenshot',
|
|
463
424
|
timestamp,
|
|
425
|
+
journey,
|
|
464
426
|
step,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
text,
|
|
468
|
-
type,
|
|
469
|
-
} as Payload,
|
|
427
|
+
blob: data,
|
|
428
|
+
blob_mime: 'image/jpeg',
|
|
470
429
|
});
|
|
471
|
-
}
|
|
430
|
+
}
|
|
472
431
|
}
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
if (networkinfo) {
|
|
436
|
+
networkinfo.forEach(ni => {
|
|
437
|
+
const { ecs, payload } = formatNetworkFields(ni);
|
|
438
|
+
this.writeJSON({
|
|
439
|
+
type: 'journey/network_info',
|
|
440
|
+
journey,
|
|
441
|
+
timestamp: ni.timestamp,
|
|
442
|
+
root_fields: snakeCaseKeys(ecs),
|
|
443
|
+
step: ni.step,
|
|
444
|
+
payload: snakeCaseKeys(payload),
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
}
|
|
473
448
|
|
|
449
|
+
if (browserconsole) {
|
|
450
|
+
browserconsole.forEach(({ timestamp, text, type, step, error }) => {
|
|
474
451
|
this.writeJSON({
|
|
475
|
-
type: 'journey/
|
|
452
|
+
type: 'journey/browserconsole',
|
|
476
453
|
journey,
|
|
477
454
|
timestamp,
|
|
455
|
+
step,
|
|
478
456
|
error,
|
|
479
457
|
payload: {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
},
|
|
458
|
+
text,
|
|
459
|
+
type,
|
|
460
|
+
} as Payload,
|
|
484
461
|
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
this.writeJSON({
|
|
466
|
+
type: 'journey/end',
|
|
467
|
+
journey,
|
|
468
|
+
timestamp,
|
|
469
|
+
error,
|
|
470
|
+
payload: {
|
|
471
|
+
start,
|
|
472
|
+
end,
|
|
473
|
+
status,
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
override onEnd() {
|
|
479
|
+
this.stream.flushSync();
|
|
488
480
|
}
|
|
489
481
|
|
|
490
482
|
async writeScreenshotBlocks(journey: Journey, screenshot: Screenshot) {
|
package/src/reporters/junit.ts
CHANGED
|
@@ -23,8 +23,14 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import { mkdir, writeFile } from 'fs/promises';
|
|
27
27
|
import { dirname } from 'path';
|
|
28
|
+
import {
|
|
29
|
+
JourneyEndResult,
|
|
30
|
+
JourneyStartResult,
|
|
31
|
+
StepEndResult,
|
|
32
|
+
} from '../common_types';
|
|
33
|
+
import { Journey, Step } from '../dsl';
|
|
28
34
|
import { formatError, indent, now } from '../helpers';
|
|
29
35
|
import BaseReporter from './base';
|
|
30
36
|
|
|
@@ -51,104 +57,103 @@ export default class JUnitReporter extends BaseReporter {
|
|
|
51
57
|
private totalTests = 0;
|
|
52
58
|
private totalFailures = 0;
|
|
53
59
|
private totalSkipped = 0;
|
|
60
|
+
#journeyMap = new Map<string, XMLEntry>();
|
|
54
61
|
|
|
55
|
-
override
|
|
56
|
-
|
|
62
|
+
override onJourneyStart(journey: Journey, {}: JourneyStartResult) {
|
|
63
|
+
if (!this.#journeyMap.has(journey.name)) {
|
|
64
|
+
const entry = {
|
|
65
|
+
name: 'testsuite',
|
|
66
|
+
attributes: {
|
|
67
|
+
name: journey.name,
|
|
68
|
+
tests: 0,
|
|
69
|
+
failures: 0,
|
|
70
|
+
skipped: 0,
|
|
71
|
+
errors: 0,
|
|
72
|
+
},
|
|
73
|
+
children: [],
|
|
74
|
+
};
|
|
75
|
+
this.#journeyMap.set(journey.name, entry);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
57
78
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
override onStepEnd(
|
|
80
|
+
journey: Journey,
|
|
81
|
+
step: Step,
|
|
82
|
+
{ status, error, start, end }: StepEndResult
|
|
83
|
+
) {
|
|
84
|
+
if (!this.#journeyMap.has(journey.name)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const entry = this.#journeyMap.get(journey.name);
|
|
88
|
+
const caseEntry = {
|
|
89
|
+
name: 'testcase',
|
|
90
|
+
attributes: {
|
|
91
|
+
name: step.name,
|
|
92
|
+
classname: journey.name + ' ' + step.name,
|
|
93
|
+
time: end - start,
|
|
94
|
+
},
|
|
95
|
+
children: [],
|
|
96
|
+
};
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
entry.attributes.tests++;
|
|
99
|
+
if (status === 'failed') {
|
|
100
|
+
const { name, message, stack } = formatError(error);
|
|
101
|
+
caseEntry.children.push({
|
|
102
|
+
name: 'failure',
|
|
103
|
+
attributes: {
|
|
104
|
+
message,
|
|
105
|
+
type: name,
|
|
106
|
+
},
|
|
107
|
+
text: stack,
|
|
108
|
+
});
|
|
109
|
+
entry.attributes.failures++;
|
|
110
|
+
} else if (status === 'skipped') {
|
|
111
|
+
caseEntry.children.push({
|
|
112
|
+
name: 'skipped',
|
|
113
|
+
attributes: {
|
|
114
|
+
message: 'previous step failed',
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
entry.attributes.skipped++;
|
|
118
|
+
}
|
|
119
|
+
entry.children.push(caseEntry);
|
|
120
|
+
}
|
|
91
121
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
text: stack,
|
|
102
|
-
});
|
|
103
|
-
entry.attributes.failures++;
|
|
104
|
-
} else if (status === 'skipped') {
|
|
105
|
-
caseEntry.children.push({
|
|
106
|
-
name: 'skipped',
|
|
107
|
-
attributes: {
|
|
108
|
-
message: 'previous step failed',
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
entry.attributes.skipped++;
|
|
112
|
-
}
|
|
113
|
-
entry.children.push(caseEntry);
|
|
114
|
-
}
|
|
115
|
-
);
|
|
122
|
+
override onJourneyEnd(journey: Journey, {}: JourneyEndResult) {
|
|
123
|
+
if (!this.#journeyMap.has(journey.name)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const { attributes } = this.#journeyMap.get(journey.name);
|
|
127
|
+
this.totalTests += attributes.tests;
|
|
128
|
+
this.totalFailures += attributes.failures;
|
|
129
|
+
this.totalSkipped += attributes.skipped;
|
|
130
|
+
}
|
|
116
131
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
override async onEnd() {
|
|
133
|
+
const root: XMLEntry = {
|
|
134
|
+
name: 'testsuites',
|
|
135
|
+
attributes: {
|
|
136
|
+
name: '',
|
|
137
|
+
tests: this.totalTests,
|
|
138
|
+
failures: this.totalFailures,
|
|
139
|
+
skipped: this.totalSkipped,
|
|
140
|
+
errors: 0,
|
|
141
|
+
time: parseInt(String(now())) / 1000,
|
|
142
|
+
},
|
|
143
|
+
children: [...this.#journeyMap.values()],
|
|
144
|
+
};
|
|
126
145
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
children: [...journeyMap.values()],
|
|
139
|
-
};
|
|
140
|
-
const output = serializeEntries(root).join('\n');
|
|
141
|
-
/**
|
|
142
|
-
* write the xml output to a file if specified via env flag
|
|
143
|
-
*/
|
|
144
|
-
const fileName = process.env['SYNTHETICS_JUNIT_FILE'];
|
|
145
|
-
if (fileName) {
|
|
146
|
-
mkdirSync(dirname(fileName), { recursive: true });
|
|
147
|
-
writeFileSync(fileName, output);
|
|
148
|
-
} else {
|
|
149
|
-
this.write(output);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
146
|
+
const output = serializeEntries(root).join('\n');
|
|
147
|
+
/**
|
|
148
|
+
* write the xml output to a file if specified via env flag
|
|
149
|
+
*/
|
|
150
|
+
const fileName = process.env['SYNTHETICS_JUNIT_FILE'];
|
|
151
|
+
if (fileName) {
|
|
152
|
+
await mkdir(dirname(fileName), { recursive: true });
|
|
153
|
+
await writeFile(fileName, output);
|
|
154
|
+
} else {
|
|
155
|
+
this.write(output);
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
159
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { journey, step, monitor, expect } from '@elastic/synthetics';
|
|
2
|
+
|
|
3
|
+
journey('My Example Journey', ({ page, params }) => {
|
|
4
|
+
// Only relevant for the push command to create
|
|
5
|
+
// monitors in Kibana
|
|
6
|
+
monitor.use({
|
|
7
|
+
id: 'example-monitor',
|
|
8
|
+
schedule: 10,
|
|
9
|
+
});
|
|
10
|
+
step('launch application', async () => {
|
|
11
|
+
await page.goto(params.url);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
step('assert title', async () => {
|
|
15
|
+
const header = await page.$('h1');
|
|
16
|
+
expect(await header.textContent()).toBe('todos');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SyntheticsConfig } from '@elastic/synthetics';
|
|
2
|
+
|
|
3
|
+
export default env => {
|
|
4
|
+
const config: SyntheticsConfig = {
|
|
5
|
+
params: {
|
|
6
|
+
url: 'https://elastic.github.io/synthetics-demo/',
|
|
7
|
+
},
|
|
8
|
+
playwrightOptions: {
|
|
9
|
+
ignoreHTTPSErrors: false,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
if (env !== 'development') {
|
|
13
|
+
/**
|
|
14
|
+
* Override configuration specific to environment
|
|
15
|
+
* Ex: config.params.url = ""
|
|
16
|
+
*/
|
|
17
|
+
}
|
|
18
|
+
return config;
|
|
19
|
+
};
|