@elastic/synthetics 1.4.0 → 1.5.1
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/bundles/lib/index.js +432 -0
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +12 -2
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -1
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.js +2 -2
- package/dist/core/browser-service.js.map +1 -1
- package/dist/core/expect.d.ts +1 -152
- package/dist/core/expect.d.ts.map +1 -1
- package/dist/core/expect.js +14 -5
- package/dist/core/expect.js.map +1 -1
- package/dist/core/gatherer.d.ts +1 -1
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +5 -5
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +8 -7
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +1 -1
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/monitor.d.ts +4 -0
- package/dist/dsl/monitor.d.ts.map +1 -1
- package/dist/dsl/monitor.js.map +1 -1
- package/dist/helpers.d.ts +0 -5
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1 -24
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/options.d.ts +2 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +13 -4
- package/dist/options.js.map +1 -1
- package/dist/plugins/browser-console.d.ts +3 -2
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +33 -7
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/network.d.ts +1 -0
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +15 -2
- package/dist/plugins/network.js.map +1 -1
- package/dist/push/kibana_api.d.ts.map +1 -1
- package/dist/push/kibana_api.js +1 -1
- package/dist/push/kibana_api.js.map +1 -1
- package/dist/push/monitor.d.ts.map +1 -1
- package/dist/push/monitor.js +10 -2
- package/dist/push/monitor.js.map +1 -1
- package/dist/push/request.d.ts.map +1 -1
- package/dist/push/request.js +4 -3
- package/dist/push/request.js.map +1 -1
- package/dist/push/utils.js +1 -1
- package/dist/push/utils.js.map +1 -1
- package/dist/reporters/base.d.ts +3 -0
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +20 -22
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +1 -0
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +34 -1
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +4 -4
- package/dist/reporters/junit.js.map +1 -1
- package/dist/reporters/reporter-util.d.ts +35 -0
- package/dist/reporters/reporter-util.d.ts.map +1 -0
- package/dist/reporters/reporter-util.js +192 -0
- package/dist/reporters/reporter-util.js.map +1 -0
- package/package.json +16 -8
- package/src/cli.ts +3 -3
- package/src/common_types.ts +15 -2
- package/src/config.ts +12 -1
- package/src/core/browser-service.ts +1 -1
- package/src/core/expect.ts +13 -191
- package/src/core/gatherer.ts +1 -1
- package/src/core/runner.ts +15 -9
- package/src/dsl/journey.ts +1 -1
- package/src/dsl/monitor.ts +4 -0
- package/src/helpers.ts +0 -24
- package/src/index.ts +1 -1
- package/src/options.ts +16 -4
- package/src/plugins/browser-console.ts +39 -8
- package/src/plugins/network.ts +16 -3
- package/src/push/kibana_api.ts +4 -3
- package/src/push/monitor.ts +13 -2
- package/src/push/request.ts +12 -4
- package/src/push/utils.ts +1 -1
- package/src/reporters/base.ts +26 -33
- package/src/reporters/index.ts +5 -1
- package/src/reporters/json.ts +39 -3
- package/src/reporters/junit.ts +5 -5
- package/src/reporters/reporter-util.ts +217 -0
|
@@ -0,0 +1,192 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.stripAnsiCodes = exports.renderError = exports.serializeError = exports.highLightSource = exports.prepareError = void 0;
|
|
31
|
+
const url_1 = require("url");
|
|
32
|
+
const path_1 = require("path");
|
|
33
|
+
const fs_1 = require("fs");
|
|
34
|
+
const util_1 = require("util");
|
|
35
|
+
const colors_1 = require("kleur/colors");
|
|
36
|
+
const code_frame_1 = require("@babel/code-frame");
|
|
37
|
+
const stack_utils_1 = __importDefault(require("stack-utils"));
|
|
38
|
+
const stackUtils = new stack_utils_1.default({ internals: stack_utils_1.default.nodeInternals() });
|
|
39
|
+
const SYNTHETICS_PATH = (0, path_1.resolve)(__dirname, '..', '..');
|
|
40
|
+
const PW_CORE_PATH = require.resolve('playwright-core');
|
|
41
|
+
function prepareStackFrame(line) {
|
|
42
|
+
const frame = stackUtils.parseLine(line);
|
|
43
|
+
if (!frame) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// ignore node internals
|
|
47
|
+
if (frame.file?.startsWith('internal') || frame.file?.startsWith('node:')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// handle relative URLs
|
|
51
|
+
let file = frame.file?.startsWith('file://')
|
|
52
|
+
? (0, url_1.fileURLToPath)(frame.file)
|
|
53
|
+
: (0, path_1.resolve)(process.cwd(), frame.file);
|
|
54
|
+
// ignore node_modules
|
|
55
|
+
if (file.includes(`${path_1.sep}node_modules${path_1.sep}`)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// filter library and PW files
|
|
59
|
+
if (!filterLibInternals(file)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// When we bundle the journeys, we store the absolute path of the journey
|
|
63
|
+
// files and write the sourcemap relative to these files. When we try to
|
|
64
|
+
// extract the sourcemap file location, the stacktrace will be relatively
|
|
65
|
+
// resolved to these files which would be under `journeys` folder. So we strip
|
|
66
|
+
// these extra `journeys` from the path to get the correct file location.
|
|
67
|
+
if (frame.file?.includes('journeys/journeys')) {
|
|
68
|
+
file = file.replace('journeys/journeys', 'journeys');
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
file,
|
|
72
|
+
line: frame.line || 0,
|
|
73
|
+
column: frame.column || 0,
|
|
74
|
+
function: frame.function,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function filterLibInternals(file) {
|
|
78
|
+
// To ignore filtering the stack trace on tests
|
|
79
|
+
if (process.env.TEST_OVERRIDE) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (file.startsWith(SYNTHETICS_PATH)) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// should have been filtered by node_modules, but just in case
|
|
86
|
+
if (file.startsWith(PW_CORE_PATH)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function constructStackFromFrames(frames) {
|
|
91
|
+
const stackLines = [];
|
|
92
|
+
for (const frame of frames) {
|
|
93
|
+
stackLines.push(` at ${frame.function ? frame.function + ' ' : ''}(${frame.file}:${frame.line}:${frame.column})`);
|
|
94
|
+
}
|
|
95
|
+
return stackLines;
|
|
96
|
+
}
|
|
97
|
+
function prepareError(error) {
|
|
98
|
+
const stack = error.stack;
|
|
99
|
+
const lines = stack.split('\n');
|
|
100
|
+
let startAt = lines.findIndex(line => line.startsWith(' at '));
|
|
101
|
+
if (startAt === -1) {
|
|
102
|
+
startAt = lines.length;
|
|
103
|
+
}
|
|
104
|
+
const message = lines.slice(0, startAt).join('\n');
|
|
105
|
+
const stackLines = lines.slice(startAt);
|
|
106
|
+
// figure out the location of the journey/step that throws the error and
|
|
107
|
+
// correct stack line corresponding to that error
|
|
108
|
+
const stackFrames = [];
|
|
109
|
+
for (const line of stackLines) {
|
|
110
|
+
const frame = prepareStackFrame(line);
|
|
111
|
+
if (!frame || !frame.file) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
stackFrames.push(frame);
|
|
115
|
+
}
|
|
116
|
+
let location;
|
|
117
|
+
if (stackFrames.length) {
|
|
118
|
+
const frame = stackFrames[0];
|
|
119
|
+
location = {
|
|
120
|
+
file: frame.file,
|
|
121
|
+
column: frame.column || 0,
|
|
122
|
+
line: frame.line || 0,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
message,
|
|
127
|
+
stack: constructStackFromFrames(stackFrames).join('\n'),
|
|
128
|
+
location,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.prepareError = prepareError;
|
|
132
|
+
function highLightSource(location) {
|
|
133
|
+
if (!location) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const source = (0, fs_1.readFileSync)(location.file, 'utf-8');
|
|
138
|
+
const code = (0, code_frame_1.codeFrameColumns)(source, { start: location }, { highlightCode: true });
|
|
139
|
+
return code;
|
|
140
|
+
}
|
|
141
|
+
catch (_) {
|
|
142
|
+
// ignore error
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.highLightSource = highLightSource;
|
|
146
|
+
// serializeError prefers receiving proper Errors, but since at runtime
|
|
147
|
+
// non Error exceptions can be thrown, it tolerates though. The
|
|
148
|
+
// redundant type Error | any expresses that.
|
|
149
|
+
function serializeError(error, highlightCode = true) {
|
|
150
|
+
if (!(error instanceof Error) || !error.stack) {
|
|
151
|
+
return { message: `thrown: ${(0, util_1.inspect)(error)}` };
|
|
152
|
+
}
|
|
153
|
+
const testErr = { message: error.message };
|
|
154
|
+
const { message, stack, location } = prepareError(error);
|
|
155
|
+
testErr.message = message;
|
|
156
|
+
if (stack) {
|
|
157
|
+
testErr.stack = stack;
|
|
158
|
+
}
|
|
159
|
+
if (location && highlightCode) {
|
|
160
|
+
testErr.location = location;
|
|
161
|
+
testErr.source = highLightSource(testErr.location);
|
|
162
|
+
}
|
|
163
|
+
return testErr;
|
|
164
|
+
}
|
|
165
|
+
exports.serializeError = serializeError;
|
|
166
|
+
function renderError(error) {
|
|
167
|
+
const summary = [];
|
|
168
|
+
// push empty string to add a new line before rendering error
|
|
169
|
+
summary.push('');
|
|
170
|
+
summary.push(error.message);
|
|
171
|
+
if (error.source) {
|
|
172
|
+
summary.push('');
|
|
173
|
+
summary.push(error.source);
|
|
174
|
+
}
|
|
175
|
+
if (error.stack) {
|
|
176
|
+
summary.push('');
|
|
177
|
+
summary.push((0, colors_1.gray)(error.stack));
|
|
178
|
+
}
|
|
179
|
+
summary.join('');
|
|
180
|
+
return summary.join('\n');
|
|
181
|
+
}
|
|
182
|
+
exports.renderError = renderError;
|
|
183
|
+
// strip color codes and ansi escape codes
|
|
184
|
+
const ansiRegex = new RegExp([
|
|
185
|
+
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
186
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
|
|
187
|
+
].join('|'), 'g');
|
|
188
|
+
function stripAnsiCodes(msg = '') {
|
|
189
|
+
return msg.replace(ansiRegex, '');
|
|
190
|
+
}
|
|
191
|
+
exports.stripAnsiCodes = stripAnsiCodes;
|
|
192
|
+
//# sourceMappingURL=reporter-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter-util.js","sourceRoot":"","sources":["../../src/reporters/reporter-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,6BAAoC;AACpC,+BAAoC;AACpC,2BAAkC;AAClC,+BAA+B;AAC/B,yCAAoC;AACpC,kDAAqD;AACrD,8DAAqC;AAGrC,MAAM,UAAU,GAAG,IAAI,qBAAU,CAAC,EAAE,SAAS,EAAE,qBAAU,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAE7E,MAAM,eAAe,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACvD,MAAM,YAAY,G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,CAAC;AAlBD,kCAkBC;AAED,0CAA0C;AAC1C,MAAM,SAAS,GAAG,IAAI,MAAM,CAC1B;IACE,8HAA8H;IAC9H,0DAA0D;CAC3D,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,GAAG,CACJ,CAAC;AACF,SAAgB,cAAc,CAAC,GAAG,GAAG,EAAE;IACrC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAFD,wCAEC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/synthetics",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Elastic synthetic monitoring agent",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean": "rimraf dist",
|
|
9
9
|
"prepublish": "npm run clean && npm run build",
|
|
10
|
-
"build": "tsc",
|
|
10
|
+
"build:lib": "tsc",
|
|
11
11
|
"build:locations": "sh utils/update_locations.sh",
|
|
12
|
+
"build": "node utils/build.js",
|
|
12
13
|
"watch": "tsc -w",
|
|
13
14
|
"lint": "eslint . --rulesdir utils/eslint-rules",
|
|
14
15
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -40,32 +41,38 @@
|
|
|
40
41
|
"author": "",
|
|
41
42
|
"license": "MIT",
|
|
42
43
|
"dependencies": {
|
|
44
|
+
"@babel/code-frame": "^7.22.13",
|
|
43
45
|
"archiver": "^5.3.1",
|
|
44
46
|
"commander": "^10.0.1",
|
|
45
47
|
"deepmerge": "^4.3.1",
|
|
46
48
|
"enquirer": "^2.3.6",
|
|
47
49
|
"esbuild": "^0.18.11",
|
|
48
|
-
"expect": "^28.1.3",
|
|
49
50
|
"http-proxy": "^1.18.1",
|
|
50
51
|
"kleur": "^4.1.5",
|
|
51
52
|
"micromatch": "^4.0.5",
|
|
52
53
|
"pirates": "^4.0.5",
|
|
53
|
-
"playwright
|
|
54
|
-
"playwright-
|
|
54
|
+
"playwright": "=1.38.0",
|
|
55
|
+
"playwright-chromium": "=1.38.1",
|
|
56
|
+
"playwright-core": "=1.38.1",
|
|
55
57
|
"semver": "^7.5.2",
|
|
56
|
-
"sharp": "^0.32.
|
|
58
|
+
"sharp": "^0.32.6",
|
|
57
59
|
"snakecase-keys": "^4.0.1",
|
|
58
60
|
"sonic-boom": "^3.3.0",
|
|
59
61
|
"source-map-support": "^0.5.21",
|
|
60
|
-
"
|
|
62
|
+
"stack-utils": "^2.0.6",
|
|
63
|
+
"undici": "^5.26.3",
|
|
61
64
|
"yaml": "^2.2.2"
|
|
62
65
|
},
|
|
63
66
|
"devDependencies": {
|
|
67
|
+
"@commitlint/cli": "^17.7.1",
|
|
68
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
69
|
+
"@semantic-release/exec": "^6.0.3",
|
|
70
|
+
"@types/babel__code-frame": "^7.0.3",
|
|
64
71
|
"@types/jest": "^28.1.8",
|
|
65
72
|
"@types/micromatch": "^4.0.2",
|
|
66
73
|
"@types/node": "^16.11.59",
|
|
67
|
-
"@types/sharp": "^0.28.6",
|
|
68
74
|
"@types/semver": "^7",
|
|
75
|
+
"@types/stack-utils": "^2.0.1",
|
|
69
76
|
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
70
77
|
"@typescript-eslint/parser": "^5.38.0",
|
|
71
78
|
"eslint": "^8.23.1",
|
|
@@ -76,6 +83,7 @@
|
|
|
76
83
|
"lint-staged": "^10.5.3",
|
|
77
84
|
"prettier": "^2.7.1",
|
|
78
85
|
"rimraf": "^3.0.2",
|
|
86
|
+
"semantic-release": "^21.1.1",
|
|
79
87
|
"ts-jest": "^29.1.1",
|
|
80
88
|
"typescript": "^5.1.6",
|
|
81
89
|
"unzipper": "^0.10.11"
|
package/src/cli.ts
CHANGED
|
@@ -134,7 +134,7 @@ program
|
|
|
134
134
|
.action(async (cliArgs: CliArgs) => {
|
|
135
135
|
const tearDown = await globalSetup(cliArgs, program.args);
|
|
136
136
|
try {
|
|
137
|
-
const options = normalizeOptions(cliArgs, 'run');
|
|
137
|
+
const options = await normalizeOptions(cliArgs, 'run');
|
|
138
138
|
const results = await run(options);
|
|
139
139
|
/**
|
|
140
140
|
* Exit with error status if any journey fails
|
|
@@ -196,14 +196,14 @@ program
|
|
|
196
196
|
]);
|
|
197
197
|
try {
|
|
198
198
|
const settings = await loadSettings();
|
|
199
|
-
const options = normalizeOptions(
|
|
199
|
+
const options = (await normalizeOptions(
|
|
200
200
|
{
|
|
201
201
|
...program.opts(),
|
|
202
202
|
...settings,
|
|
203
203
|
...cmdOpts,
|
|
204
204
|
},
|
|
205
205
|
'push'
|
|
206
|
-
) as PushOptions;
|
|
206
|
+
)) as PushOptions;
|
|
207
207
|
await validatePush(options, settings);
|
|
208
208
|
const monitors = runner.buildMonitors(options);
|
|
209
209
|
if ((options as CliArgs).throttling == null) {
|
package/src/common_types.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
ChromiumBrowserContext,
|
|
32
32
|
Page,
|
|
33
33
|
APIRequestContext,
|
|
34
|
-
} from 'playwright-
|
|
34
|
+
} from 'playwright-core';
|
|
35
35
|
import { Step } from './dsl';
|
|
36
36
|
import { BuiltInReporterName, ReporterInstance } from './reporters';
|
|
37
37
|
import { AlertConfig, MonitorConfig } from './dsl/monitor';
|
|
@@ -43,6 +43,10 @@ export type Location = {
|
|
|
43
43
|
column: number;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
+
export type StackFrame = Location & {
|
|
47
|
+
function?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
46
50
|
export type Params = Record<string, any>;
|
|
47
51
|
export type HooksArgs = {
|
|
48
52
|
env: string;
|
|
@@ -213,7 +217,6 @@ type BaseArgs = {
|
|
|
213
217
|
schedule?: MonitorConfig['schedule'];
|
|
214
218
|
locations?: MonitorConfig['locations'];
|
|
215
219
|
privateLocations?: MonitorConfig['privateLocations'];
|
|
216
|
-
alert?: AlertConfig;
|
|
217
220
|
};
|
|
218
221
|
|
|
219
222
|
export type CliArgs = BaseArgs & {
|
|
@@ -244,6 +247,8 @@ export type PushOptions = Partial<ProjectSettings> &
|
|
|
244
247
|
auth: string;
|
|
245
248
|
kibanaVersion?: string;
|
|
246
249
|
yes?: boolean;
|
|
250
|
+
alert?: AlertConfig;
|
|
251
|
+
retestOnFailure?: MonitorConfig['retestOnFailure'];
|
|
247
252
|
};
|
|
248
253
|
|
|
249
254
|
export type ProjectSettings = {
|
|
@@ -274,6 +279,14 @@ export type JourneyResult = {
|
|
|
274
279
|
browserconsole?: PluginOutput['browserconsole'];
|
|
275
280
|
};
|
|
276
281
|
|
|
282
|
+
export type TestError = {
|
|
283
|
+
message: string;
|
|
284
|
+
stack?: string;
|
|
285
|
+
location?: Location;
|
|
286
|
+
// source location highlighting the error source
|
|
287
|
+
source?: string;
|
|
288
|
+
};
|
|
289
|
+
|
|
277
290
|
export type StepResult = {
|
|
278
291
|
status: StatusValue;
|
|
279
292
|
url?: string;
|
package/src/config.ts
CHANGED
|
@@ -27,7 +27,10 @@ import { isAbsolute, resolve, dirname } from 'path';
|
|
|
27
27
|
import { SyntheticsConfig } from './common_types';
|
|
28
28
|
import { isFile } from './helpers';
|
|
29
29
|
|
|
30
|
-
export function readConfig(
|
|
30
|
+
export async function readConfig(
|
|
31
|
+
env: string,
|
|
32
|
+
config?: string
|
|
33
|
+
): Promise<SyntheticsConfig> {
|
|
31
34
|
let options = {};
|
|
32
35
|
const cwd = process.cwd();
|
|
33
36
|
/**
|
|
@@ -47,6 +50,14 @@ export function readConfig(env: string, config?: string): SyntheticsConfig {
|
|
|
47
50
|
}
|
|
48
51
|
if (typeof options === 'function') {
|
|
49
52
|
options = options(env);
|
|
53
|
+
const optionsPromise = options as Promise<SyntheticsConfig>;
|
|
54
|
+
if (
|
|
55
|
+
optionsPromise != null &&
|
|
56
|
+
typeof optionsPromise.then === 'function' &&
|
|
57
|
+
typeof optionsPromise.catch === 'function'
|
|
58
|
+
) {
|
|
59
|
+
options = await optionsPromise;
|
|
60
|
+
}
|
|
50
61
|
}
|
|
51
62
|
return options;
|
|
52
63
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import { URL } from 'url';
|
|
27
27
|
import { createServer } from 'http';
|
|
28
28
|
import { createProxyServer } from 'http-proxy';
|
|
29
|
-
import { chromium } from 'playwright-
|
|
29
|
+
import { chromium } from 'playwright-core';
|
|
30
30
|
import { log } from './logger';
|
|
31
31
|
|
|
32
32
|
export class BrowserService {
|
package/src/core/expect.ts
CHANGED
|
@@ -23,199 +23,21 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
AsymmetricMatcher,
|
|
29
|
-
MatcherState,
|
|
30
|
-
ExpectedAssertionsErrors,
|
|
31
|
-
Inverse,
|
|
32
|
-
PromiseMatchers,
|
|
33
|
-
} from 'expect/build/types';
|
|
26
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
27
|
+
const expectLib = require('../../dist/bundles/lib/index').expect;
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
assertions(arg0: number): void;
|
|
39
|
-
extend(arg0: any): void;
|
|
40
|
-
extractExpectedAssertionsErrors: () => ExpectedAssertionsErrors;
|
|
41
|
-
getState(): MatcherState;
|
|
42
|
-
hasAssertions(): void;
|
|
43
|
-
setState(state: Partial<MatcherState>): void;
|
|
44
|
-
any(expectedObject: any): AsymmetricMatcher;
|
|
45
|
-
anything(): AsymmetricMatcher;
|
|
46
|
-
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
|
|
47
|
-
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
|
|
48
|
-
stringContaining(expected: string): AsymmetricMatcher;
|
|
49
|
-
stringMatching(expected: string | RegExp): AsymmetricMatcher;
|
|
50
|
-
};
|
|
29
|
+
function notSupported(name: string) {
|
|
30
|
+
throw new Error(`expect.${name} is not supported in @elastic/synthetics.`);
|
|
31
|
+
}
|
|
51
32
|
|
|
52
33
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* impelemed via jest matchers
|
|
56
|
-
*
|
|
57
|
-
* We declare the types in global synthetics namespace which allows
|
|
58
|
-
* users to extend expect functionality without type errors
|
|
34
|
+
* Exclude toHaveScreenshot and toMatchSnapshot from our custom expect
|
|
35
|
+
* since they are expected to be running inside PW test runner for it to work properly.
|
|
59
36
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* If you know how to test something, `.not` lets you test its opposite.
|
|
65
|
-
*/
|
|
66
|
-
not: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
67
|
-
/**
|
|
68
|
-
* Use resolves to unwrap the value of a fulfilled promise so any other
|
|
69
|
-
* matcher can be chained. If the promise is rejected the assertion fails.
|
|
70
|
-
*/
|
|
71
|
-
resolves: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
72
|
-
/**
|
|
73
|
-
* Unwraps the reason of a rejected promise so any other matcher can be chained.
|
|
74
|
-
* If the promise is fulfilled the assertion fails.
|
|
75
|
-
*/
|
|
76
|
-
rejects: Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
77
|
-
/**
|
|
78
|
-
* Checks that a value is what you expect. It uses `===` to check strict equality.
|
|
79
|
-
* Don't use `toBe` with floating-point numbers.
|
|
80
|
-
*/
|
|
81
|
-
toBe(
|
|
82
|
-
expected: unknown
|
|
83
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
84
|
-
/**
|
|
85
|
-
* Using exact equality with floating point numbers is a bad idea.
|
|
86
|
-
* Rounding means that intuitive things fail.
|
|
87
|
-
* The default for numDigits is 2.
|
|
88
|
-
*/
|
|
89
|
-
toBeCloseTo(
|
|
90
|
-
expected: number,
|
|
91
|
-
numDigits?: number
|
|
92
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
93
|
-
/**
|
|
94
|
-
* Ensure that a variable is not undefined.
|
|
95
|
-
*/
|
|
96
|
-
toBeDefined(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
97
|
-
/**
|
|
98
|
-
* When you don't care what a value is, you just want to
|
|
99
|
-
* ensure a value is false in a boolean context.
|
|
100
|
-
*/
|
|
101
|
-
toBeFalsy(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
102
|
-
/**
|
|
103
|
-
* For comparing floating point numbers.
|
|
104
|
-
*/
|
|
105
|
-
toBeGreaterThan(
|
|
106
|
-
expected: number | bigint
|
|
107
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
108
|
-
/**
|
|
109
|
-
* For comparing floating point numbers.
|
|
110
|
-
*/
|
|
111
|
-
toBeGreaterThanOrEqual(
|
|
112
|
-
expected: number | bigint
|
|
113
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
114
|
-
/**
|
|
115
|
-
* Ensure that an object is an instance of a class.
|
|
116
|
-
* This matcher uses `instanceof` underneath.
|
|
117
|
-
*/
|
|
118
|
-
/* eslint-disable-next-line */
|
|
119
|
-
toBeInstanceOf(
|
|
120
|
-
expected: unknown
|
|
121
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
122
|
-
/**
|
|
123
|
-
* For comparing floating point numbers.
|
|
124
|
-
*/
|
|
125
|
-
toBeLessThan(
|
|
126
|
-
expected: number | bigint
|
|
127
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
128
|
-
/**
|
|
129
|
-
* For comparing floating point numbers.
|
|
130
|
-
*/
|
|
131
|
-
toBeLessThanOrEqual(
|
|
132
|
-
expected: number | bigint
|
|
133
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
134
|
-
/**
|
|
135
|
-
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
|
|
136
|
-
* So use `.toBeNull()` when you want to check that something is null.
|
|
137
|
-
*/
|
|
138
|
-
toBeNull(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
139
|
-
/**
|
|
140
|
-
* Use when you don't care what a value is, you just want to ensure a value
|
|
141
|
-
* is true in a boolean context. In JavaScript, there are six falsy values:
|
|
142
|
-
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
|
|
143
|
-
*/
|
|
144
|
-
toBeTruthy(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
145
|
-
/**
|
|
146
|
-
* Used to check that a variable is undefined.
|
|
147
|
-
*/
|
|
148
|
-
toBeUndefined(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
149
|
-
/**
|
|
150
|
-
* Used to check that a variable is NaN.
|
|
151
|
-
*/
|
|
152
|
-
toBeNaN(): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
153
|
-
/**
|
|
154
|
-
* Used when you want to check that an item is in a list.
|
|
155
|
-
* For testing the items in the list, this uses `===`, a strict equality check.
|
|
156
|
-
*/
|
|
157
|
-
toContain(
|
|
158
|
-
expected: unknown
|
|
159
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
160
|
-
/**
|
|
161
|
-
* Used when you want to check that an item is in a list.
|
|
162
|
-
* For testing the items in the list, this matcher recursively checks the
|
|
163
|
-
* equality of all fields, rather than checking for object identity.
|
|
164
|
-
*/
|
|
165
|
-
toContainEqual(
|
|
166
|
-
expected: unknown
|
|
167
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
168
|
-
/**
|
|
169
|
-
* Used when you want to check that two objects have the same value.
|
|
170
|
-
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
|
|
171
|
-
*/
|
|
172
|
-
toEqual(
|
|
173
|
-
expected: unknown
|
|
174
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
175
|
-
/**
|
|
176
|
-
* Used to check that an object has a `.length` property
|
|
177
|
-
* and it is set to a certain numeric value.
|
|
178
|
-
*/
|
|
179
|
-
toHaveLength(
|
|
180
|
-
expected: number
|
|
181
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
182
|
-
/**
|
|
183
|
-
* Use to check if property at provided reference keyPath exists for an object.
|
|
184
|
-
* For checking deeply nested properties in an object you may use dot notation or an array containing
|
|
185
|
-
* the keyPath for deep references.
|
|
186
|
-
*
|
|
187
|
-
* Optionally, you can provide a value to check if it's equal to the value present at keyPath
|
|
188
|
-
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
|
|
189
|
-
* the equality of all fields.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
*
|
|
193
|
-
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
|
|
194
|
-
*/
|
|
195
|
-
toHaveProperty(
|
|
196
|
-
keyPath: string | Array<string>,
|
|
197
|
-
value?: unknown
|
|
198
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
199
|
-
/**
|
|
200
|
-
* Check that a string matches a regular expression.
|
|
201
|
-
*/
|
|
202
|
-
toMatch(
|
|
203
|
-
expected: string | RegExp
|
|
204
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
205
|
-
/**
|
|
206
|
-
* Used to check that a JavaScript object matches a subset of the properties of an object
|
|
207
|
-
*/
|
|
208
|
-
toMatchObject(
|
|
209
|
-
expected: Record<string, unknown> | Array<unknown>
|
|
210
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
211
|
-
/**
|
|
212
|
-
* Use to test that objects have the same types as well as structure.
|
|
213
|
-
*/
|
|
214
|
-
toStrictEqual(
|
|
215
|
-
expected: unknown
|
|
216
|
-
): Matchers<R> & Inverse<Matchers<R>> & PromiseMatchers;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
37
|
+
expectLib.extend({
|
|
38
|
+
toHaveScreenshot: () => notSupported('toHaveScreenshot'),
|
|
39
|
+
toMatchSnapshot: () => notSupported('toMatchSnapshot'),
|
|
40
|
+
});
|
|
220
41
|
|
|
221
|
-
export const expect:
|
|
42
|
+
export const expect: typeof import('../../bundles/node_modules/playwright/types/test').expect =
|
|
43
|
+
expectLib;
|
package/src/core/gatherer.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
BrowserContext,
|
|
30
30
|
request as apiRequest,
|
|
31
31
|
selectors,
|
|
32
|
-
} from 'playwright-
|
|
32
|
+
} from 'playwright-core';
|
|
33
33
|
import { PluginManager } from '../plugins';
|
|
34
34
|
import { log } from './logger';
|
|
35
35
|
import { Driver, NetworkConditions, RunOptions } from '../common_types';
|
package/src/core/runner.ts
CHANGED
|
@@ -46,8 +46,11 @@ import {
|
|
|
46
46
|
StepResult,
|
|
47
47
|
PushOptions,
|
|
48
48
|
} from '../common_types';
|
|
49
|
-
import {
|
|
50
|
-
|
|
49
|
+
import {
|
|
50
|
+
PluginManager,
|
|
51
|
+
PerformanceManager,
|
|
52
|
+
filterBrowserMessages,
|
|
53
|
+
} from '../plugins';
|
|
51
54
|
import { Gatherer } from './gatherer';
|
|
52
55
|
import { log } from './logger';
|
|
53
56
|
import { Monitor, MonitorConfig } from '../dsl/monitor';
|
|
@@ -149,12 +152,12 @@ export default class Runner {
|
|
|
149
152
|
* Set up the corresponding reporter and fallback
|
|
150
153
|
* to default reporter if not provided
|
|
151
154
|
*/
|
|
152
|
-
const { reporter, outfd } = options;
|
|
155
|
+
const { reporter, outfd, dryRun } = options;
|
|
153
156
|
const Reporter =
|
|
154
157
|
typeof reporter === 'function'
|
|
155
158
|
? reporter
|
|
156
159
|
: reporters[reporter] || reporters['default'];
|
|
157
|
-
this.#reporter = new Reporter({ fd: outfd });
|
|
160
|
+
this.#reporter = new Reporter({ fd: outfd, dryRun });
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
async runBeforeAllHook(args: HooksArgs) {
|
|
@@ -209,8 +212,9 @@ export default class Runner {
|
|
|
209
212
|
*/
|
|
210
213
|
pluginManager.onStep(step);
|
|
211
214
|
traceEnabled && (await pluginManager.start('trace'));
|
|
212
|
-
//
|
|
213
|
-
|
|
215
|
+
// invoke the step callback by extracting to a variable to get better stack trace
|
|
216
|
+
const cb = step.callback;
|
|
217
|
+
await cb();
|
|
214
218
|
} catch (error) {
|
|
215
219
|
data.status = 'failed';
|
|
216
220
|
data.error = error;
|
|
@@ -288,8 +292,7 @@ export default class Runner {
|
|
|
288
292
|
params,
|
|
289
293
|
});
|
|
290
294
|
/**
|
|
291
|
-
* Exeucute the journey callback which
|
|
292
|
-
* register the steps for the current journey
|
|
295
|
+
* Exeucute the journey callback which registers the steps for current journey
|
|
293
296
|
*/
|
|
294
297
|
journey.callback({ ...context.driver, params });
|
|
295
298
|
}
|
|
@@ -310,7 +313,10 @@ export default class Runner {
|
|
|
310
313
|
timestamp: getTimestamp(),
|
|
311
314
|
options,
|
|
312
315
|
...pluginOutput,
|
|
313
|
-
browserconsole:
|
|
316
|
+
browserconsole: filterBrowserMessages(
|
|
317
|
+
pluginOutput.browserconsole,
|
|
318
|
+
status
|
|
319
|
+
),
|
|
314
320
|
});
|
|
315
321
|
// clear screenshots cache after each journey
|
|
316
322
|
await rm(Runner.screenshotPath, { recursive: true, force: true });
|