@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.
Files changed (131) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +42 -5
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +62 -14
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/core/gatherer.d.ts +2 -2
  7. package/dist/core/gatherer.d.ts.map +1 -1
  8. package/dist/core/gatherer.js +14 -5
  9. package/dist/core/gatherer.js.map +1 -1
  10. package/dist/core/index.d.ts +4 -0
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +15 -1
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/runner.d.ts +10 -58
  15. package/dist/core/runner.d.ts.map +1 -1
  16. package/dist/core/runner.js +89 -50
  17. package/dist/core/runner.js.map +1 -1
  18. package/dist/dsl/journey.d.ts +3 -0
  19. package/dist/dsl/journey.d.ts.map +1 -1
  20. package/dist/dsl/journey.js +15 -0
  21. package/dist/dsl/journey.js.map +1 -1
  22. package/dist/dsl/monitor.d.ts +64 -0
  23. package/dist/dsl/monitor.d.ts.map +1 -0
  24. package/dist/dsl/monitor.js +62 -0
  25. package/dist/dsl/monitor.js.map +1 -0
  26. package/dist/formatter/javascript.d.ts +1 -1
  27. package/dist/formatter/javascript.d.ts.map +1 -1
  28. package/dist/formatter/javascript.js +1 -1
  29. package/dist/formatter/javascript.js.map +1 -1
  30. package/dist/generator/index.d.ts +13 -0
  31. package/dist/generator/index.d.ts.map +1 -0
  32. package/dist/generator/index.js +123 -0
  33. package/dist/generator/index.js.map +1 -0
  34. package/dist/{reporters/reporter.js → generator/utils.d.ts} +3 -3
  35. package/dist/generator/utils.d.ts.map +1 -0
  36. package/dist/generator/utils.js +44 -0
  37. package/dist/generator/utils.js.map +1 -0
  38. package/dist/helpers.d.ts +12 -6
  39. package/dist/helpers.d.ts.map +1 -1
  40. package/dist/helpers.js +33 -43
  41. package/dist/helpers.js.map +1 -1
  42. package/dist/index.d.ts +3 -9
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -5
  45. package/dist/index.js.map +1 -1
  46. package/dist/loader.js +4 -4
  47. package/dist/loader.js.map +1 -1
  48. package/dist/options.d.ts +12 -0
  49. package/dist/options.d.ts.map +1 -1
  50. package/dist/options.js +66 -4
  51. package/dist/options.js.map +1 -1
  52. package/dist/plugins/network.d.ts +17 -30
  53. package/dist/plugins/network.d.ts.map +1 -1
  54. package/dist/plugins/network.js +179 -244
  55. package/dist/plugins/network.js.map +1 -1
  56. package/dist/plugins/performance.d.ts +1 -16
  57. package/dist/plugins/performance.d.ts.map +1 -1
  58. package/dist/plugins/performance.js.map +1 -1
  59. package/dist/plugins/plugin-manager.d.ts +2 -2
  60. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  61. package/dist/plugins/plugin-manager.js +2 -2
  62. package/dist/plugins/plugin-manager.js.map +1 -1
  63. package/dist/push/bundler.d.ts +34 -0
  64. package/dist/push/bundler.d.ts.map +1 -0
  65. package/dist/push/bundler.js +119 -0
  66. package/dist/push/bundler.js.map +1 -0
  67. package/{src/reporters/reporter.ts → dist/push/index.d.ts} +4 -11
  68. package/dist/push/index.d.ts.map +1 -0
  69. package/dist/push/index.js +58 -0
  70. package/dist/push/index.js.map +1 -0
  71. package/dist/{reporters/reporter.d.ts → push/monitor.d.ts} +7 -8
  72. package/dist/push/monitor.d.ts.map +1 -0
  73. package/dist/push/monitor.js +67 -0
  74. package/dist/push/monitor.js.map +1 -0
  75. package/dist/push/plugin.d.ts +33 -0
  76. package/dist/push/plugin.d.ts.map +1 -0
  77. package/dist/push/plugin.js +123 -0
  78. package/dist/push/plugin.js.map +1 -0
  79. package/dist/push/request.d.ts +43 -0
  80. package/dist/push/request.d.ts.map +1 -0
  81. package/dist/push/request.js +95 -0
  82. package/dist/push/request.js.map +1 -0
  83. package/dist/reporters/base.d.ts +14 -6
  84. package/dist/reporters/base.d.ts.map +1 -1
  85. package/dist/reporters/base.js +45 -47
  86. package/dist/reporters/base.js.map +1 -1
  87. package/dist/reporters/index.d.ts +18 -8
  88. package/dist/reporters/index.d.ts.map +1 -1
  89. package/dist/reporters/index.js.map +1 -1
  90. package/dist/reporters/json.d.ts +7 -4
  91. package/dist/reporters/json.d.ts.map +1 -1
  92. package/dist/reporters/json.js +119 -137
  93. package/dist/reporters/json.js.map +1 -1
  94. package/dist/reporters/junit.d.ts +7 -1
  95. package/dist/reporters/junit.d.ts.map +1 -1
  96. package/dist/reporters/junit.js +91 -86
  97. package/dist/reporters/junit.js.map +1 -1
  98. package/dist/tsconfig.tsbuildinfo +1 -1
  99. package/package.json +14 -9
  100. package/src/cli.ts +65 -9
  101. package/src/common_types.ts +72 -14
  102. package/src/core/gatherer.ts +18 -10
  103. package/src/core/index.ts +15 -0
  104. package/src/core/runner.ts +87 -114
  105. package/src/dsl/journey.ts +18 -0
  106. package/src/dsl/monitor.ts +83 -0
  107. package/src/formatter/javascript.ts +1 -1
  108. package/src/generator/index.ts +159 -0
  109. package/src/generator/utils.ts +41 -0
  110. package/src/helpers.ts +36 -52
  111. package/src/index.ts +10 -2
  112. package/src/loader.ts +4 -4
  113. package/src/options.ts +71 -8
  114. package/src/plugins/network.ts +218 -293
  115. package/src/plugins/performance.ts +1 -17
  116. package/src/plugins/plugin-manager.ts +2 -2
  117. package/src/push/bundler.ts +99 -0
  118. package/src/push/index.ts +63 -0
  119. package/src/push/monitor.ts +77 -0
  120. package/src/push/plugin.ts +113 -0
  121. package/src/push/request.ts +123 -0
  122. package/src/reporters/base.ts +57 -56
  123. package/src/reporters/index.ts +26 -3
  124. package/src/reporters/json.ts +154 -162
  125. package/src/reporters/junit.ts +98 -93
  126. package/templates/journeys/example.journey.ts +18 -0
  127. package/templates/synthetics.config.ts +19 -0
  128. package/CHANGELOG.md +0 -339
  129. package/NOTICE.txt +0 -250
  130. package/dist/reporters/reporter.d.ts.map +0 -1
  131. package/dist/reporters/reporter.js.map +0 -1
@@ -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
- override _registerListeners() {
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.runner.on('start', ({ numJourneys, networkConditions }) => {
321
- this.writeJSON({
322
- type: 'synthetics/metadata',
323
- root_fields: {
324
- num_journeys: numJourneys,
325
- },
326
- payload: networkConditions
327
- ? {
328
- network_conditions: networkConditions,
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
- this.runner.on('journey:register', ({ journey }) => {
335
- this.writeJSON({
336
- type: 'journey/register',
337
- journey,
338
- });
321
+ onJourneyRegister(journey: Journey): void {
322
+ this.writeJSON({
323
+ type: 'journey/register',
324
+ journey,
339
325
  });
326
+ }
340
327
 
341
- this.runner.on('journey:start', ({ journey, timestamp, params }) => {
342
- this.writeJSON({
343
- type: 'journey/start',
344
- journey,
345
- timestamp,
346
- payload: { params, source: journey.callback.toString() },
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
- this.runner.on(
351
- 'step:end',
352
- ({
353
- journey,
354
- step,
355
- start,
356
- end,
357
- error,
358
- url,
359
- status,
360
- pagemetrics,
361
- traces,
362
- metrics,
363
- filmstrips,
364
- }) => {
365
- this.writeMetrics(journey, step, 'relative_trace', traces);
366
- this.writeMetrics(journey, step, 'experience', metrics);
367
- if (filmstrips) {
368
- // Write each filmstrip separately so that we don't get documents that are too large
369
- filmstrips.forEach((strip, index) => {
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/end',
361
+ type: 'step/filmstrips',
385
362
  journey,
386
- step: {
387
- ...step,
388
- duration: {
389
- us: getDurationInUs(end - start),
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.runner.on(
405
- 'journey:end',
406
- async ({
407
- journey,
408
- timestamp,
409
- start,
410
- end,
411
- networkinfo,
412
- browserconsole,
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
- error,
415
- options,
416
- }) => {
417
- const { ssblocks, screenshots } = options;
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
- if (networkinfo) {
446
- networkinfo.forEach(ni => {
447
- const { ecs, payload } = formatNetworkFields(ni);
448
- this.writeJSON({
449
- type: 'journey/network_info',
450
- journey,
451
- timestamp: ni.timestamp,
452
- root_fields: snakeCaseKeys(ecs),
453
- step: ni.step,
454
- payload: snakeCaseKeys(payload),
455
- });
456
- });
457
- }
458
- if (browserconsole) {
459
- browserconsole.forEach(({ timestamp, text, type, step, error }) => {
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: 'journey/browserconsole',
462
- journey,
423
+ type: 'step/screenshot',
463
424
  timestamp,
425
+ journey,
464
426
  step,
465
- error,
466
- payload: {
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/end',
452
+ type: 'journey/browserconsole',
476
453
  journey,
477
454
  timestamp,
455
+ step,
478
456
  error,
479
457
  payload: {
480
- start,
481
- end,
482
- status,
483
- },
458
+ text,
459
+ type,
460
+ } as Payload,
484
461
  });
485
- process.nextTick(() => this.runner.emit('journey:end:reported', {}));
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) {
@@ -23,8 +23,14 @@
23
23
  *
24
24
  */
25
25
 
26
- import { mkdirSync, writeFileSync } from 'fs';
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 _registerListeners() {
56
- const journeyMap = new Map<string, XMLEntry>();
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
- this.runner.on('journey:start', ({ journey }) => {
59
- if (!journeyMap.has(journey.name)) {
60
- const entry = {
61
- name: 'testsuite',
62
- attributes: {
63
- name: journey.name,
64
- tests: 0,
65
- failures: 0,
66
- skipped: 0,
67
- errors: 0,
68
- },
69
- children: [],
70
- };
71
- journeyMap.set(journey.name, entry);
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
- this.runner.on(
76
- 'step:end',
77
- ({ journey, step, status, error, start, end }) => {
78
- if (!journeyMap.has(journey.name)) {
79
- return;
80
- }
81
- const entry = journeyMap.get(journey.name);
82
- const caseEntry = {
83
- name: 'testcase',
84
- attributes: {
85
- name: step.name,
86
- classname: journey.name + ' ' + step.name,
87
- time: end - start,
88
- },
89
- children: [],
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
- entry.attributes.tests++;
93
- if (status === 'failed') {
94
- const { name, message, stack } = formatError(error);
95
- caseEntry.children.push({
96
- name: 'failure',
97
- attributes: {
98
- message,
99
- type: name,
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
- this.runner.on('journey:end', ({ journey }) => {
118
- if (!journeyMap.has(journey.name)) {
119
- return;
120
- }
121
- const { attributes } = journeyMap.get(journey.name);
122
- this.totalTests += attributes.tests;
123
- this.totalFailures += attributes.failures;
124
- this.totalSkipped += attributes.skipped;
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
- this.runner.on('end', () => {
128
- const root: XMLEntry = {
129
- name: 'testsuites',
130
- attributes: {
131
- name: '',
132
- tests: this.totalTests,
133
- failures: this.totalFailures,
134
- skipped: this.totalSkipped,
135
- errors: 0,
136
- time: parseInt(String(now())) / 1000,
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
+ };