@elastic/synthetics 1.0.0-beta.30 → 1.0.0-beta.33
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/dist/cli.js +51 -26
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +4 -1
- package/dist/common_types.d.ts.map +1 -1
- package/dist/core/expect.d.ts +25 -25
- package/dist/core/expect.d.ts.map +1 -1
- package/dist/core/expect.js.map +1 -1
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +3 -1
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +4 -3
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/index.js +5 -1
- package/dist/dsl/index.js.map +1 -1
- package/dist/dsl/journey.d.ts +2 -1
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +5 -1
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +2 -1
- package/dist/dsl/monitor.d.ts.map +1 -1
- package/dist/dsl/monitor.js +2 -2
- package/dist/dsl/monitor.js.map +1 -1
- package/dist/generator/index.d.ts +11 -3
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +98 -27
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/utils.d.ts +2 -1
- package/dist/generator/utils.d.ts.map +1 -1
- package/dist/generator/utils.js +27 -4
- package/dist/generator/utils.js.map +1 -1
- package/dist/helpers.d.ts +10 -5
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +41 -10
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/loader.js +11 -3
- package/dist/loader.js.map +1 -1
- package/dist/locations/index.d.ts +45 -0
- package/dist/locations/index.d.ts.map +1 -0
- package/dist/locations/index.js +90 -0
- package/dist/locations/index.js.map +1 -0
- package/dist/{dsl/locations.d.ts → locations/public-locations.d.ts} +1 -1
- package/dist/locations/public-locations.d.ts.map +1 -0
- package/dist/{dsl/locations.js → locations/public-locations.js} +1 -1
- package/dist/locations/public-locations.js.map +1 -0
- package/dist/options.d.ts +7 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +21 -1
- package/dist/options.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/push/bundler.d.ts.map +1 -1
- package/dist/push/bundler.js +12 -3
- package/dist/push/bundler.js.map +1 -1
- package/dist/push/index.d.ts +12 -1
- package/dist/push/index.d.ts.map +1 -1
- package/dist/push/index.js +137 -8
- package/dist/push/index.js.map +1 -1
- package/dist/push/monitor.d.ts +7 -0
- package/dist/push/monitor.d.ts.map +1 -1
- package/dist/push/monitor.js +23 -7
- package/dist/push/monitor.js.map +1 -1
- package/dist/push/plugin.d.ts.map +1 -1
- package/dist/push/plugin.js +11 -2
- package/dist/push/plugin.js.map +1 -1
- package/dist/push/request.d.ts +8 -7
- package/dist/push/request.d.ts.map +1 -1
- package/dist/push/request.js +22 -22
- package/dist/push/request.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/cli.ts +79 -59
- package/src/common_types.ts +4 -0
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +9 -2
- package/src/core/runner.ts +5 -6
- package/src/dsl/journey.ts +8 -1
- package/src/dsl/monitor.ts +2 -1
- package/src/generator/index.ts +138 -34
- package/src/generator/utils.ts +29 -3
- package/src/helpers.ts +40 -12
- package/src/index.ts +1 -0
- package/src/loader.ts +11 -2
- package/src/locations/index.ts +108 -0
- package/src/{dsl/locations.ts → locations/public-locations.ts} +0 -0
- package/src/options.ts +38 -0
- package/src/push/bundler.ts +7 -2
- package/src/push/index.ts +177 -10
- package/src/push/monitor.ts +38 -9
- package/src/push/plugin.ts +6 -1
- package/src/push/request.ts +27 -34
- package/templates/journeys/advanced-example-helpers.ts +9 -9
- package/templates/journeys/advanced-example.journey.ts +6 -6
- package/templates/journeys/example.journey.ts +1 -1
- package/templates/synthetics.config.ts +2 -1
- package/dist/dsl/locations.d.ts.map +0 -1
- package/dist/dsl/locations.js.map +0 -1
package/src/cli.ts
CHANGED
|
@@ -29,19 +29,37 @@ import { program, Option } from 'commander';
|
|
|
29
29
|
import { cwd } from 'process';
|
|
30
30
|
import { CliArgs, PushOptions } from './common_types';
|
|
31
31
|
import { reporters } from './reporters';
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
normalizeOptions,
|
|
34
|
+
parseThrottling,
|
|
35
|
+
getCommonCommandOpts,
|
|
36
|
+
} from './options';
|
|
33
37
|
import { loadTestFiles } from './loader';
|
|
34
38
|
import { run } from './';
|
|
35
39
|
import { runner } from './core';
|
|
36
40
|
import { SyntheticsLocations } from './dsl/monitor';
|
|
37
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
push,
|
|
43
|
+
loadSettings,
|
|
44
|
+
validateSettings,
|
|
45
|
+
catchIncorrectSettings,
|
|
46
|
+
} from './push';
|
|
47
|
+
import {
|
|
48
|
+
formatLocations,
|
|
49
|
+
getLocations,
|
|
50
|
+
renderLocations,
|
|
51
|
+
LocationCmdOptions,
|
|
52
|
+
} from './locations';
|
|
38
53
|
import { resolve } from 'path';
|
|
39
54
|
import { Generator } from './generator';
|
|
40
55
|
import { error } from './helpers';
|
|
56
|
+
import { LocationsMap } from './locations/public-locations';
|
|
41
57
|
|
|
42
58
|
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
43
59
|
const { name, version } = require('../package.json');
|
|
44
60
|
|
|
61
|
+
const { params, pattern, tags, match, playwrightOpts } = getCommonCommandOpts();
|
|
62
|
+
|
|
45
63
|
program
|
|
46
64
|
.name(`npx ${name}`)
|
|
47
65
|
.usage('[options] [dir] [files] file')
|
|
@@ -49,20 +67,15 @@ program
|
|
|
49
67
|
'-c, --config <path>',
|
|
50
68
|
'configuration path (default: synthetics.config.js)'
|
|
51
69
|
)
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
70
|
+
.addOption(pattern)
|
|
71
|
+
.addOption(tags)
|
|
72
|
+
.addOption(match)
|
|
73
|
+
.addOption(params)
|
|
57
74
|
.addOption(
|
|
58
75
|
new Option('--reporter <value>', `output repoter format`).choices(
|
|
59
76
|
Object.keys(reporters)
|
|
60
77
|
)
|
|
61
78
|
)
|
|
62
|
-
.option(
|
|
63
|
-
'--pattern <pattern>',
|
|
64
|
-
'RegExp file patterns to search inside directory'
|
|
65
|
-
)
|
|
66
79
|
.option('--inline', 'Run inline journeys from heartbeat')
|
|
67
80
|
.option('-r, --require <modules...>', 'module(s) to preload')
|
|
68
81
|
.option('--no-headless', 'run browser in headful mode')
|
|
@@ -81,14 +94,6 @@ program
|
|
|
81
94
|
'--dry-run',
|
|
82
95
|
"don't actually execute anything, report only registered journeys"
|
|
83
96
|
)
|
|
84
|
-
.option(
|
|
85
|
-
'--tags <name...>',
|
|
86
|
-
'run only journeys with a tag that matches the glob'
|
|
87
|
-
)
|
|
88
|
-
.option(
|
|
89
|
-
'--match <name>',
|
|
90
|
-
'run only journeys with a name or tag that matches the glob'
|
|
91
|
-
)
|
|
92
97
|
.option(
|
|
93
98
|
'--outfd <fd>',
|
|
94
99
|
'specify a file descriptor for logs. Default is stdout',
|
|
@@ -117,11 +122,7 @@ program
|
|
|
117
122
|
{}
|
|
118
123
|
)
|
|
119
124
|
.option('--no-throttling', 'Turns off default network throttling.')
|
|
120
|
-
.
|
|
121
|
-
'--playwright-options <jsonstring>',
|
|
122
|
-
'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.',
|
|
123
|
-
JSON.parse
|
|
124
|
-
)
|
|
125
|
+
.addOption(playwrightOpts)
|
|
125
126
|
.version(version)
|
|
126
127
|
.description('Run synthetic tests')
|
|
127
128
|
.action(async (cliArgs: CliArgs) => {
|
|
@@ -149,19 +150,11 @@ program
|
|
|
149
150
|
program
|
|
150
151
|
.command('push')
|
|
151
152
|
.description(
|
|
152
|
-
'Push journeys in the current directory to create monitors within the Kibana monitor management UI'
|
|
153
|
+
'Push all journeys in the current directory to create monitors within the Kibana monitor management UI'
|
|
153
154
|
)
|
|
154
|
-
.
|
|
155
|
-
'--
|
|
156
|
-
'
|
|
157
|
-
)
|
|
158
|
-
.option(
|
|
159
|
-
'--tags <name...>',
|
|
160
|
-
'push only journeys with a tag that matches the glob'
|
|
161
|
-
)
|
|
162
|
-
.option(
|
|
163
|
-
'--match <name>',
|
|
164
|
-
'push only journeys with a name or tag that matches the glob'
|
|
155
|
+
.requiredOption(
|
|
156
|
+
'--auth <auth>',
|
|
157
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
165
158
|
)
|
|
166
159
|
.option(
|
|
167
160
|
'--schedule <time-in-minutes>',
|
|
@@ -174,35 +167,37 @@ program
|
|
|
174
167
|
'default list of locations from which your monitors will run.'
|
|
175
168
|
).choices(SyntheticsLocations)
|
|
176
169
|
)
|
|
177
|
-
.
|
|
178
|
-
'--
|
|
179
|
-
'
|
|
170
|
+
.option(
|
|
171
|
+
'--private-locations <locations...>',
|
|
172
|
+
'default list of private locations from which your monitors will run.'
|
|
180
173
|
)
|
|
181
|
-
.
|
|
182
|
-
.
|
|
183
|
-
'--
|
|
184
|
-
'
|
|
174
|
+
.option('--url <url>', 'Kibana URL to upload the monitors')
|
|
175
|
+
.option(
|
|
176
|
+
'--project <id>',
|
|
177
|
+
'id that will be used for logically grouping monitors'
|
|
185
178
|
)
|
|
186
179
|
.option(
|
|
187
180
|
'--space <space>',
|
|
188
|
-
'the target Kibana spaces for the pushed monitors — spaces help you organise pushed monitors.'
|
|
189
|
-
'default'
|
|
181
|
+
'the target Kibana spaces for the pushed monitors — spaces help you organise pushed monitors.'
|
|
190
182
|
)
|
|
183
|
+
.addOption(pattern)
|
|
184
|
+
.addOption(tags)
|
|
185
|
+
.addOption(match)
|
|
186
|
+
.addOption(params)
|
|
187
|
+
.addOption(playwrightOpts)
|
|
191
188
|
.action(async (cmdOpts: PushOptions) => {
|
|
192
189
|
try {
|
|
190
|
+
const settings = await loadSettings();
|
|
193
191
|
await loadTestFiles({ inline: false }, [cwd()]);
|
|
194
|
-
const options = normalizeOptions({
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
throw error(`Set default location for all monitors via CLI as '--locations <locations...>' OR
|
|
202
|
-
configure via Synthetics config file under 'monitors.locations' field.`);
|
|
203
|
-
}
|
|
192
|
+
const options = normalizeOptions({
|
|
193
|
+
...program.opts(),
|
|
194
|
+
...settings,
|
|
195
|
+
...cmdOpts,
|
|
196
|
+
}) as PushOptions;
|
|
197
|
+
validateSettings(options);
|
|
198
|
+
await catchIncorrectSettings(settings, options);
|
|
204
199
|
const monitors = runner.buildMonitors(options);
|
|
205
|
-
await push(monitors,
|
|
200
|
+
await push(monitors, options);
|
|
206
201
|
} catch (e) {
|
|
207
202
|
e && console.error(e);
|
|
208
203
|
process.exit(1);
|
|
@@ -211,9 +206,9 @@ program
|
|
|
211
206
|
|
|
212
207
|
// Init command
|
|
213
208
|
program
|
|
214
|
-
.command('init
|
|
215
|
-
.description('
|
|
216
|
-
.action(async (dir
|
|
209
|
+
.command('init [dir]')
|
|
210
|
+
.description('Initialize Elastic synthetics project')
|
|
211
|
+
.action(async (dir = '') => {
|
|
217
212
|
try {
|
|
218
213
|
const generator = await new Generator(resolve(process.cwd(), dir));
|
|
219
214
|
await generator.setup();
|
|
@@ -223,4 +218,29 @@ program
|
|
|
223
218
|
}
|
|
224
219
|
});
|
|
225
220
|
|
|
221
|
+
// Locations command
|
|
222
|
+
program
|
|
223
|
+
.command('locations')
|
|
224
|
+
.description(
|
|
225
|
+
`List all locations to run the synthetics monitors. Pass optional '--url' and '--auth' to list private locations.`
|
|
226
|
+
)
|
|
227
|
+
.option('--url <url>', 'Kibana URL to fetch all public and private locations')
|
|
228
|
+
.option(
|
|
229
|
+
'--auth <auth>',
|
|
230
|
+
'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).'
|
|
231
|
+
)
|
|
232
|
+
.action(async (cmdOpts: LocationCmdOptions) => {
|
|
233
|
+
try {
|
|
234
|
+
let locations = Object.keys(LocationsMap);
|
|
235
|
+
if (cmdOpts.auth && cmdOpts.url) {
|
|
236
|
+
const allLocations = await getLocations(cmdOpts);
|
|
237
|
+
locations = formatLocations(allLocations);
|
|
238
|
+
}
|
|
239
|
+
renderLocations(locations);
|
|
240
|
+
} catch (e) {
|
|
241
|
+
e && error(e);
|
|
242
|
+
process.exit(1);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
226
246
|
program.parse(process.argv);
|
package/src/common_types.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
ChromiumBrowser,
|
|
31
31
|
ChromiumBrowserContext,
|
|
32
32
|
Page,
|
|
33
|
+
APIRequestContext,
|
|
33
34
|
} from 'playwright-chromium';
|
|
34
35
|
import { Step } from './dsl';
|
|
35
36
|
import { BuiltInReporterName, ReporterInstance } from './reporters';
|
|
@@ -62,6 +63,7 @@ export type Driver = {
|
|
|
62
63
|
context: ChromiumBrowserContext;
|
|
63
64
|
page: Page;
|
|
64
65
|
client: CDPSession;
|
|
66
|
+
request: APIRequestContext;
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
export type TraceOutput = {
|
|
@@ -210,6 +212,7 @@ type BaseArgs = {
|
|
|
210
212
|
throttling?: ThrottlingOptions;
|
|
211
213
|
schedule?: MonitorConfig['schedule'];
|
|
212
214
|
locations?: MonitorConfig['locations'];
|
|
215
|
+
privateLocations?: MonitorConfig['privateLocations'];
|
|
213
216
|
};
|
|
214
217
|
|
|
215
218
|
export type CliArgs = BaseArgs & {
|
|
@@ -245,6 +248,7 @@ export type PushOptions = {
|
|
|
245
248
|
space: string;
|
|
246
249
|
schedule?: MonitorConfig['schedule'];
|
|
247
250
|
locations?: MonitorConfig['locations'];
|
|
251
|
+
privateLocations?: MonitorConfig['privateLocations'];
|
|
248
252
|
};
|
|
249
253
|
|
|
250
254
|
export type PlaywrightOptions = LaunchOptions & BrowserContextOptions;
|
package/src/core/expect.ts
CHANGED
|
@@ -28,6 +28,8 @@ import type {
|
|
|
28
28
|
AsymmetricMatcher,
|
|
29
29
|
MatcherState,
|
|
30
30
|
ExpectedAssertionsErrors,
|
|
31
|
+
Inverse,
|
|
32
|
+
PromiseMatchers,
|
|
31
33
|
} from 'expect/build/types';
|
|
32
34
|
|
|
33
35
|
// Copied source code from expect/build/types.d.ts
|
|
@@ -61,99 +63,122 @@ declare global {
|
|
|
61
63
|
/**
|
|
62
64
|
* If you know how to test something, `.not` lets you test its opposite.
|
|
63
65
|
*/
|
|
64
|
-
not: Matchers<R
|
|
66
|
+
not: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
65
67
|
/**
|
|
66
68
|
* Use resolves to unwrap the value of a fulfilled promise so any other
|
|
67
69
|
* matcher can be chained. If the promise is rejected the assertion fails.
|
|
68
70
|
*/
|
|
69
|
-
resolves: Matchers<
|
|
71
|
+
resolves: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
70
72
|
/**
|
|
71
73
|
* Unwraps the reason of a rejected promise so any other matcher can be chained.
|
|
72
74
|
* If the promise is fulfilled the assertion fails.
|
|
73
75
|
*/
|
|
74
|
-
rejects: Matchers<
|
|
76
|
+
rejects: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
75
77
|
/**
|
|
76
78
|
* Checks that a value is what you expect. It uses `===` to check strict equality.
|
|
77
79
|
* Don't use `toBe` with floating-point numbers.
|
|
78
80
|
*/
|
|
79
|
-
toBe(
|
|
81
|
+
toBe(
|
|
82
|
+
expected: unknown
|
|
83
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
80
84
|
/**
|
|
81
85
|
* Using exact equality with floating point numbers is a bad idea.
|
|
82
86
|
* Rounding means that intuitive things fail.
|
|
83
87
|
* The default for numDigits is 2.
|
|
84
88
|
*/
|
|
85
|
-
toBeCloseTo(
|
|
89
|
+
toBeCloseTo(
|
|
90
|
+
expected: number,
|
|
91
|
+
numDigits?: number
|
|
92
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
86
93
|
/**
|
|
87
94
|
* Ensure that a variable is not undefined.
|
|
88
95
|
*/
|
|
89
|
-
toBeDefined(): R;
|
|
96
|
+
toBeDefined(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
90
97
|
/**
|
|
91
98
|
* When you don't care what a value is, you just want to
|
|
92
99
|
* ensure a value is false in a boolean context.
|
|
93
100
|
*/
|
|
94
|
-
toBeFalsy(): R;
|
|
101
|
+
toBeFalsy(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
95
102
|
/**
|
|
96
103
|
* For comparing floating point numbers.
|
|
97
104
|
*/
|
|
98
|
-
toBeGreaterThan(
|
|
105
|
+
toBeGreaterThan(
|
|
106
|
+
expected: number | bigint
|
|
107
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
99
108
|
/**
|
|
100
109
|
* For comparing floating point numbers.
|
|
101
110
|
*/
|
|
102
|
-
toBeGreaterThanOrEqual(
|
|
111
|
+
toBeGreaterThanOrEqual(
|
|
112
|
+
expected: number | bigint
|
|
113
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
103
114
|
/**
|
|
104
115
|
* Ensure that an object is an instance of a class.
|
|
105
116
|
* This matcher uses `instanceof` underneath.
|
|
106
117
|
*/
|
|
107
118
|
/* eslint-disable-next-line */
|
|
108
|
-
toBeInstanceOf(
|
|
119
|
+
toBeInstanceOf(
|
|
120
|
+
expected: unknown
|
|
121
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
109
122
|
/**
|
|
110
123
|
* For comparing floating point numbers.
|
|
111
124
|
*/
|
|
112
|
-
toBeLessThan(
|
|
125
|
+
toBeLessThan(
|
|
126
|
+
expected: number | bigint
|
|
127
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
113
128
|
/**
|
|
114
129
|
* For comparing floating point numbers.
|
|
115
130
|
*/
|
|
116
|
-
toBeLessThanOrEqual(
|
|
131
|
+
toBeLessThanOrEqual(
|
|
132
|
+
expected: number | bigint
|
|
133
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
117
134
|
/**
|
|
118
135
|
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
|
|
119
136
|
* So use `.toBeNull()` when you want to check that something is null.
|
|
120
137
|
*/
|
|
121
|
-
toBeNull(): R;
|
|
138
|
+
toBeNull(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
122
139
|
/**
|
|
123
140
|
* Use when you don't care what a value is, you just want to ensure a value
|
|
124
141
|
* is true in a boolean context. In JavaScript, there are six falsy values:
|
|
125
142
|
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
|
|
126
143
|
*/
|
|
127
|
-
toBeTruthy(): R;
|
|
144
|
+
toBeTruthy(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
128
145
|
/**
|
|
129
146
|
* Used to check that a variable is undefined.
|
|
130
147
|
*/
|
|
131
|
-
toBeUndefined(): R;
|
|
148
|
+
toBeUndefined(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
132
149
|
/**
|
|
133
150
|
* Used to check that a variable is NaN.
|
|
134
151
|
*/
|
|
135
|
-
toBeNaN(): R;
|
|
152
|
+
toBeNaN(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
136
153
|
/**
|
|
137
154
|
* Used when you want to check that an item is in a list.
|
|
138
155
|
* For testing the items in the list, this uses `===`, a strict equality check.
|
|
139
156
|
*/
|
|
140
|
-
toContain(
|
|
157
|
+
toContain(
|
|
158
|
+
expected: unknown
|
|
159
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
141
160
|
/**
|
|
142
161
|
* Used when you want to check that an item is in a list.
|
|
143
162
|
* For testing the items in the list, this matcher recursively checks the
|
|
144
163
|
* equality of all fields, rather than checking for object identity.
|
|
145
164
|
*/
|
|
146
|
-
toContainEqual(
|
|
165
|
+
toContainEqual(
|
|
166
|
+
expected: unknown
|
|
167
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
147
168
|
/**
|
|
148
169
|
* Used when you want to check that two objects have the same value.
|
|
149
170
|
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
|
|
150
171
|
*/
|
|
151
|
-
toEqual(
|
|
172
|
+
toEqual(
|
|
173
|
+
expected: unknown
|
|
174
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
152
175
|
/**
|
|
153
176
|
* Used to check that an object has a `.length` property
|
|
154
177
|
* and it is set to a certain numeric value.
|
|
155
178
|
*/
|
|
156
|
-
toHaveLength(
|
|
179
|
+
toHaveLength(
|
|
180
|
+
expected: number
|
|
181
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
157
182
|
/**
|
|
158
183
|
* Use to check if property at provided reference keyPath exists for an object.
|
|
159
184
|
* For checking deeply nested properties in an object you may use dot notation or an array containing
|
|
@@ -167,19 +192,28 @@ declare global {
|
|
|
167
192
|
*
|
|
168
193
|
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
|
|
169
194
|
*/
|
|
170
|
-
toHaveProperty(
|
|
195
|
+
toHaveProperty(
|
|
196
|
+
keyPath: string | Array<string>,
|
|
197
|
+
value?: unknown
|
|
198
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
171
199
|
/**
|
|
172
200
|
* Check that a string matches a regular expression.
|
|
173
201
|
*/
|
|
174
|
-
toMatch(
|
|
202
|
+
toMatch(
|
|
203
|
+
expected: string | RegExp
|
|
204
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
175
205
|
/**
|
|
176
206
|
* Used to check that a JavaScript object matches a subset of the properties of an object
|
|
177
207
|
*/
|
|
178
|
-
toMatchObject(
|
|
208
|
+
toMatchObject(
|
|
209
|
+
expected: Record<string, unknown> | Array<unknown>
|
|
210
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
179
211
|
/**
|
|
180
212
|
* Use to test that objects have the same types as well as structure.
|
|
181
213
|
*/
|
|
182
|
-
toStrictEqual(
|
|
214
|
+
toStrictEqual(
|
|
215
|
+
expected: unknown
|
|
216
|
+
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
183
217
|
}
|
|
184
218
|
}
|
|
185
219
|
}
|
package/src/core/gatherer.ts
CHANGED
|
@@ -23,7 +23,12 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
chromium,
|
|
28
|
+
ChromiumBrowser,
|
|
29
|
+
BrowserContext,
|
|
30
|
+
request as apiRequest,
|
|
31
|
+
} from 'playwright-chromium';
|
|
27
32
|
import { PluginManager } from '../plugins';
|
|
28
33
|
import { log } from './logger';
|
|
29
34
|
import { Driver, NetworkConditions, RunOptions } from '../common_types';
|
|
@@ -61,7 +66,8 @@ export class Gatherer {
|
|
|
61
66
|
|
|
62
67
|
const page = await context.newPage();
|
|
63
68
|
const client = await context.newCDPSession(page);
|
|
64
|
-
|
|
69
|
+
const request = await apiRequest.newContext({ ...playwrightOptions });
|
|
70
|
+
return { browser: Gatherer.browser, context, page, client, request };
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
static async getUserAgent(userAgent?: string) {
|
|
@@ -114,6 +120,7 @@ export class Gatherer {
|
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
static async dispose(driver: Driver) {
|
|
123
|
+
await driver.request.dispose();
|
|
117
124
|
await driver.context.close();
|
|
118
125
|
}
|
|
119
126
|
|
package/src/core/runner.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import { join } from 'path';
|
|
27
|
-
import { rm } from 'fs/promises';
|
|
27
|
+
import { mkdir, rm, writeFile } from 'fs/promises';
|
|
28
28
|
import { Journey } from '../dsl/journey';
|
|
29
29
|
import { Step } from '../dsl/step';
|
|
30
30
|
import { reporters, Reporter } from '../reporters';
|
|
@@ -34,8 +34,6 @@ import {
|
|
|
34
34
|
getTimestamp,
|
|
35
35
|
runParallel,
|
|
36
36
|
generateUniqueId,
|
|
37
|
-
mkdirAsync,
|
|
38
|
-
writeFileAsync,
|
|
39
37
|
} from '../helpers';
|
|
40
38
|
import {
|
|
41
39
|
HooksCallback,
|
|
@@ -87,7 +85,7 @@ export default class Runner {
|
|
|
87
85
|
* For each journey we create the screenshots folder for
|
|
88
86
|
* caching all screenshots and clear them at end of each journey
|
|
89
87
|
*/
|
|
90
|
-
await
|
|
88
|
+
await mkdir(this.screenshotPath, { recursive: true });
|
|
91
89
|
return {
|
|
92
90
|
start,
|
|
93
91
|
params: options.params,
|
|
@@ -116,7 +114,7 @@ export default class Runner {
|
|
|
116
114
|
timestamp: getTimestamp(),
|
|
117
115
|
data: buffer.toString('base64'),
|
|
118
116
|
};
|
|
119
|
-
await
|
|
117
|
+
await writeFile(
|
|
120
118
|
join(Runner.screenshotPath, fileName),
|
|
121
119
|
JSON.stringify(screenshot)
|
|
122
120
|
);
|
|
@@ -381,7 +379,7 @@ export default class Runner {
|
|
|
381
379
|
/**
|
|
382
380
|
* Set up the directory for caching screenshots
|
|
383
381
|
*/
|
|
384
|
-
await
|
|
382
|
+
await mkdir(CACHE_PATH, { recursive: true });
|
|
385
383
|
}
|
|
386
384
|
|
|
387
385
|
buildMonitors(options: RunOptions) {
|
|
@@ -393,6 +391,7 @@ export default class Runner {
|
|
|
393
391
|
throttling: options.throttling,
|
|
394
392
|
schedule: options.schedule,
|
|
395
393
|
locations: options.locations,
|
|
394
|
+
privateLocations: options.privateLocations,
|
|
396
395
|
params: options.params,
|
|
397
396
|
playwrightOptions: options.playwrightOptions,
|
|
398
397
|
});
|
package/src/dsl/journey.ts
CHANGED
|
@@ -23,7 +23,13 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
Browser,
|
|
28
|
+
Page,
|
|
29
|
+
BrowserContext,
|
|
30
|
+
CDPSession,
|
|
31
|
+
APIRequestContext,
|
|
32
|
+
} from 'playwright-chromium';
|
|
27
33
|
import micromatch, { isMatch } from 'micromatch';
|
|
28
34
|
import { Step } from './step';
|
|
29
35
|
import { VoidCallback, HooksCallback, Params, Location } from '../common_types';
|
|
@@ -43,6 +49,7 @@ export type JourneyCallback = (options: {
|
|
|
43
49
|
browser: Browser;
|
|
44
50
|
client: CDPSession;
|
|
45
51
|
params: Params;
|
|
52
|
+
request: APIRequestContext;
|
|
46
53
|
}) => void;
|
|
47
54
|
|
|
48
55
|
export class Journey {
|
package/src/dsl/monitor.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
Params,
|
|
32
32
|
PlaywrightOptions,
|
|
33
33
|
} from '../common_types';
|
|
34
|
-
import { LocationsMap } from '
|
|
34
|
+
import { LocationsMap } from '../locations/public-locations';
|
|
35
35
|
|
|
36
36
|
export type SyntheticsLocationsType = keyof typeof LocationsMap;
|
|
37
37
|
export const SyntheticsLocations = Object.keys(
|
|
@@ -45,6 +45,7 @@ export type MonitorConfig = {
|
|
|
45
45
|
schedule?: number;
|
|
46
46
|
enabled?: boolean;
|
|
47
47
|
locations?: SyntheticsLocationsType[];
|
|
48
|
+
privateLocations?: string[];
|
|
48
49
|
throttling?: ThrottlingOptions;
|
|
49
50
|
screenshot?: ScreenshotOptions;
|
|
50
51
|
params?: Params;
|