@elastic/synthetics 1.0.0-beta.22 → 1.0.0-beta.23

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 (71) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli.js +55 -184
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +40 -27
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/core/gatherer.d.ts +1 -2
  7. package/dist/core/gatherer.d.ts.map +1 -1
  8. package/dist/core/gatherer.js +3 -4
  9. package/dist/core/gatherer.js.map +1 -1
  10. package/dist/core/index.d.ts +1 -1
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +7 -9
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/runner.d.ts +1 -8
  15. package/dist/core/runner.d.ts.map +1 -1
  16. package/dist/core/runner.js +1 -2
  17. package/dist/core/runner.js.map +1 -1
  18. package/dist/dsl/journey.d.ts +4 -3
  19. package/dist/dsl/journey.d.ts.map +1 -1
  20. package/dist/dsl/journey.js +4 -3
  21. package/dist/dsl/journey.js.map +1 -1
  22. package/dist/dsl/step.d.ts +3 -2
  23. package/dist/dsl/step.d.ts.map +1 -1
  24. package/dist/dsl/step.js +2 -1
  25. package/dist/dsl/step.js.map +1 -1
  26. package/dist/formatter/javascript.d.ts +30 -5
  27. package/dist/formatter/javascript.d.ts.map +1 -1
  28. package/dist/formatter/javascript.js +44 -23
  29. package/dist/formatter/javascript.js.map +1 -1
  30. package/dist/helpers.d.ts +2 -1
  31. package/dist/helpers.d.ts.map +1 -1
  32. package/dist/helpers.js +30 -1
  33. package/dist/helpers.js.map +1 -1
  34. package/dist/index.d.ts +3 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -18
  37. package/dist/index.js.map +1 -1
  38. package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
  39. package/dist/loader.d.ts.map +1 -0
  40. package/dist/loader.js +144 -0
  41. package/dist/loader.js.map +1 -0
  42. package/dist/options.d.ts +27 -0
  43. package/dist/options.d.ts.map +1 -0
  44. package/dist/options.js +108 -0
  45. package/dist/options.js.map +1 -0
  46. package/dist/plugins/network.d.ts +1 -4
  47. package/dist/plugins/network.d.ts.map +1 -1
  48. package/dist/plugins/network.js +2 -3
  49. package/dist/plugins/network.js.map +1 -1
  50. package/dist/reporters/json.js +5 -6
  51. package/dist/reporters/json.js.map +1 -1
  52. package/dist/sdk/trace-metrics.js +3 -4
  53. package/dist/sdk/trace-metrics.js.map +1 -1
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +3 -3
  56. package/src/cli.ts +114 -188
  57. package/src/common_types.ts +44 -27
  58. package/src/core/gatherer.ts +1 -2
  59. package/src/core/index.ts +22 -16
  60. package/src/core/runner.ts +2 -22
  61. package/src/dsl/journey.ts +10 -4
  62. package/src/dsl/step.ts +9 -2
  63. package/src/formatter/javascript.ts +58 -21
  64. package/src/helpers.ts +40 -1
  65. package/src/index.ts +10 -16
  66. package/src/loader.ts +162 -0
  67. package/src/options.ts +116 -0
  68. package/dist/parse_args.d.ts.map +0 -1
  69. package/dist/parse_args.js +0 -103
  70. package/dist/parse_args.js.map +0 -1
  71. package/src/parse_args.ts +0 -158
@@ -1,103 +0,0 @@
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
- var _a;
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.options = void 0;
29
- const commander_1 = require("commander");
30
- const reporters_1 = require("./reporters");
31
- const helpers_1 = require("./helpers");
32
- /* eslint-disable-next-line @typescript-eslint/no-var-requires */
33
- const { name, version } = require('../package.json');
34
- commander_1.program
35
- .name(`npx ${name}`)
36
- .usage('[options] [dir] [files] file')
37
- .option('-c, --config <path>', 'configuration path (default: synthetics.config.js)')
38
- .option('-p, --params <jsonstring>', 'JSON object that gets injected to all journeys', JSON.parse)
39
- .addOption(new commander_1.Option('--reporter <value>', `output repoter format`).choices(Object.keys(reporters_1.reporters)))
40
- .option('-d, --debug', 'print debug logs info')
41
- .option('--pattern <pattern>', 'RegExp file patterns to search inside directory')
42
- .option('--inline', 'Run inline journeys from heartbeat')
43
- .option('-r, --require <modules...>', 'module(s) to preload')
44
- .option('--no-headless', 'run browser in headful mode')
45
- .option('--sandbox', 'enable chromium sandboxing', false)
46
- .option('--rich-events', 'Mimics a heartbeat run')
47
- .option('--capability <features...>', 'Enable capabilities through feature flags')
48
- .addOption(new commander_1.Option('--screenshots [flag]', 'take screenshots at end of each step')
49
- .choices(['on', 'off', 'only-on-failure'])
50
- .default('on'))
51
- .option('--dry-run', "don't actually execute anything, report only registered journeys")
52
- .option('--match <name>', 'run only journeys with a name or tags that matches the glob')
53
- .option('--tags <name...>', 'run only journeys with the given tag(s), or globs')
54
- .option('--outfd <fd>', 'specify a file descriptor for logs. Default is stdout', parseInt)
55
- .option('--ws-endpoint <endpoint>', 'Browser WebSocket endpoint to connect to')
56
- .option('--pause-on-error', 'pause on error until a keypress is made in the console. Useful during development')
57
- .option('--ignore-https-errors', 'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!')
58
- .option('--quiet-exit-code', 'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run')
59
- .addOption(new commander_1.Option('--throttling <d/u/l>', 'List of options to throttle network conditions for download throughput (d) in megabits/second, upload throughput (u) in megabits/second and latency (l) in milliseconds.').default(helpers_1.DEFAULT_NETWORK_CONDITIONS_ARG))
60
- .option('--no-throttling', 'Turns off default network throttling.')
61
- .option('--playwright-options <jsonstring>', 'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file. Options defined via --playwright-options take precedence.', JSON.parse)
62
- .version(version)
63
- .description('Run synthetic tests');
64
- const command = commander_1.program.parse(process.argv);
65
- const options = command.opts();
66
- exports.options = options;
67
- /**
68
- * Group all events that can be consumed by heartbeat and
69
- * eventually by the Synthetics UI.
70
- */
71
- if (options.richEvents) {
72
- options.reporter = (_a = options.reporter) !== null && _a !== void 0 ? _a : 'json';
73
- options.ssblocks = true;
74
- options.network = true;
75
- options.quietExitCode = true;
76
- options.trace = true;
77
- }
78
- if (options.capability) {
79
- const supportedCapabilities = [
80
- 'trace',
81
- 'network',
82
- 'filmstrips',
83
- 'metrics',
84
- 'ssblocks',
85
- ];
86
- /**
87
- * trace - record chrome trace events(LCP, FCP, CLS, etc.) for all journeys
88
- * network - capture network information for all journeys
89
- * filmstrips - record detailed filmstrips for all journeys
90
- * metrics - capture performance metrics (DOM Nodes, Heap size, etc.) for each step
91
- * ssblocks - Dedupes the screenshots in to blocks to save storage space
92
- */
93
- for (const flag of options.capability) {
94
- if (supportedCapabilities.includes(flag)) {
95
- options[flag] = true;
96
- }
97
- else {
98
- console.warn(`Missing capability "${flag}", current supported capabilities are ${supportedCapabilities.join(', ')}`);
99
- }
100
- }
101
- }
102
- exports.default = command;
103
- //# sourceMappingURL=parse_args.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse_args.js","sourceRoot":"","sources":["../src/parse_args.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;AAEH,yCAA4C;AAE5C,2CAAwC;AACxC,uCAA2D;AAE3D,iEAAiE;AACjE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAErD,mBAAO;KACJ,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;KACnB,KAAK,CAAC,8BAA8B,CAAC;KACrC,MAAM,CACL,qBAAqB,EACrB,oDAAoD,CACrD;KACA,MAAM,CACL,2BAA2B,EAC3B,gDAAgD,EAChD,IAAI,CAAC,KAAK,CACX;KACA,SAAS,CACR,IAAI,kBAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC,OAAO,CAC/D,MAAM,CAAC,IAAI,CAAC,qBAAS,CAAC,CACvB,CACF;KACA,MAAM,CAAC,aAAa,EAAE,uBAAuB,CAAC;KAC9C,MAAM,CACL,qBAAqB,EACrB,iDAAiD,CAClD;KACA,MAAM,CAAC,UAAU,EAAE,oCAAoC,CAAC;KACxD,MAAM,CAAC,4BAA4B,EAAE,sBAAsB,CAAC;KAC5D,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC;KACtD,MAAM,CAAC,WAAW,EAAE,4BAA4B,EAAE,KAAK,CAAC;KACxD,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC;KACjD,MAAM,CACL,4BAA4B,EAC5B,2CAA2C,CAC5C;KACA,SAAS,CACR,IAAI,kBAAM,CAAC,sBAAsB,EAAE,sCAAsC,CAAC;KACvE,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;KACzC,OAAO,CAAC,IAAI,CAAC,CACjB;KACA,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AAC;IACF;;;;;;OAMG;IACH,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE;QACrC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACxC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;SACtB;aAAM;YACL,OAAO,CAAC,IAAI,CACV,uBAAuB,IAAI,yCAAyC,qBAAqB,CAAC,IAAI,CAC5F,IAAI,CACL,EAAE,CACJ,CAAC;SACH;KACF;CACF;AAGD,kBAAe,OAAO,CAAC"}
package/src/parse_args.ts DELETED
@@ -1,158 +0,0 @@
1
- /**
2
- * MIT License
3
- *
4
- * Copyright (c) 2020-present, Elastic NV
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
23
- *
24
- */
25
-
26
- import { program, Option } from 'commander';
27
- import { CliArgs } from './common_types';
28
- import { reporters } from './reporters';
29
- import { DEFAULT_NETWORK_CONDITIONS_ARG } from './helpers';
30
-
31
- /* eslint-disable-next-line @typescript-eslint/no-var-requires */
32
- const { name, version } = require('../package.json');
33
-
34
- program
35
- .name(`npx ${name}`)
36
- .usage('[options] [dir] [files] file')
37
- .option(
38
- '-c, --config <path>',
39
- 'configuration path (default: synthetics.config.js)'
40
- )
41
- .option(
42
- '-p, --params <jsonstring>',
43
- 'JSON object that gets injected to all journeys',
44
- JSON.parse
45
- )
46
- .addOption(
47
- new Option('--reporter <value>', `output repoter format`).choices(
48
- Object.keys(reporters)
49
- )
50
- )
51
- .option('-d, --debug', 'print debug logs info')
52
- .option(
53
- '--pattern <pattern>',
54
- 'RegExp file patterns to search inside directory'
55
- )
56
- .option('--inline', 'Run inline journeys from heartbeat')
57
- .option('-r, --require <modules...>', 'module(s) to preload')
58
- .option('--no-headless', 'run browser in headful mode')
59
- .option('--sandbox', 'enable chromium sandboxing', false)
60
- .option('--rich-events', 'Mimics a heartbeat run')
61
- .option(
62
- '--capability <features...>',
63
- 'Enable capabilities through feature flags'
64
- )
65
- .addOption(
66
- new Option('--screenshots [flag]', 'take screenshots at end of each step')
67
- .choices(['on', 'off', 'only-on-failure'])
68
- .default('on')
69
- )
70
- .option(
71
- '--dry-run',
72
- "don't actually execute anything, report only registered journeys"
73
- )
74
- .option(
75
- '--match <name>',
76
- 'run only journeys with a name or tags that matches the glob'
77
- )
78
- .option(
79
- '--tags <name...>',
80
- 'run only journeys with the given tag(s), or globs'
81
- )
82
- .option(
83
- '--outfd <fd>',
84
- 'specify a file descriptor for logs. Default is stdout',
85
- parseInt
86
- )
87
- .option(
88
- '--ws-endpoint <endpoint>',
89
- 'Browser WebSocket endpoint to connect to'
90
- )
91
- .option(
92
- '--pause-on-error',
93
- 'pause on error until a keypress is made in the console. Useful during development'
94
- )
95
- .option(
96
- '--ignore-https-errors',
97
- 'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!'
98
- )
99
- .option(
100
- '--quiet-exit-code',
101
- 'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run'
102
- )
103
- .addOption(
104
- new Option(
105
- '--throttling <d/u/l>',
106
- 'List of options to throttle network conditions for download throughput (d) in megabits/second, upload throughput (u) in megabits/second and latency (l) in milliseconds.'
107
- ).default(DEFAULT_NETWORK_CONDITIONS_ARG)
108
- )
109
- .option('--no-throttling', 'Turns off default network throttling.')
110
- .option('--playwright-options <jsonstring>', 'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file. Options defined via --playwright-options take precedence.', JSON.parse)
111
- .version(version)
112
- .description('Run synthetic tests');
113
-
114
- const command = program.parse(process.argv);
115
- const options = command.opts() as CliArgs;
116
-
117
- /**
118
- * Group all events that can be consumed by heartbeat and
119
- * eventually by the Synthetics UI.
120
- */
121
- if (options.richEvents) {
122
- options.reporter = options.reporter ?? 'json';
123
- options.ssblocks = true;
124
- options.network = true;
125
- options.quietExitCode = true;
126
- options.trace = true;
127
- }
128
-
129
- if (options.capability) {
130
- const supportedCapabilities = [
131
- 'trace',
132
- 'network',
133
- 'filmstrips',
134
- 'metrics',
135
- 'ssblocks',
136
- ];
137
- /**
138
- * trace - record chrome trace events(LCP, FCP, CLS, etc.) for all journeys
139
- * network - capture network information for all journeys
140
- * filmstrips - record detailed filmstrips for all journeys
141
- * metrics - capture performance metrics (DOM Nodes, Heap size, etc.) for each step
142
- * ssblocks - Dedupes the screenshots in to blocks to save storage space
143
- */
144
- for (const flag of options.capability) {
145
- if (supportedCapabilities.includes(flag)) {
146
- options[flag] = true;
147
- } else {
148
- console.warn(
149
- `Missing capability "${flag}", current supported capabilities are ${supportedCapabilities.join(
150
- ', '
151
- )}`
152
- );
153
- }
154
- }
155
- }
156
-
157
- export { options };
158
- export default command;