@elastic/synthetics 1.0.0-beta.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/cli.js +141 -165
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +160 -34
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -6
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.d.ts +1 -1
- package/dist/core/browser-service.d.ts.map +1 -1
- package/dist/core/browser-service.js +7 -6
- package/dist/core/browser-service.js.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 +5 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +75 -17
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -11
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +10 -17
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +12 -63
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +159 -92
- package/dist/core/runner.js.map +1 -1
- package/dist/core/transform.d.ts +37 -0
- package/dist/core/transform.d.ts.map +1 -0
- package/dist/core/transform.js +148 -0
- package/dist/core/transform.js.map +1 -0
- package/dist/dsl/index.js +5 -1
- package/dist/dsl/index.js.map +1 -1
- package/dist/dsl/journey.d.ts +9 -7
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +31 -38
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +93 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +110 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/dsl/step.d.ts +3 -2
- package/dist/dsl/step.d.ts.map +1 -1
- package/dist/dsl/step.js +6 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +115 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +331 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +24 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +242 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +84 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +37 -9
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +174 -24
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +5 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +34 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +153 -0
- package/dist/loader.js.map +1 -0
- package/dist/locations/index.d.ts +45 -0
- package/dist/locations/index.d.ts.map +1 -0
- package/dist/locations/index.js +83 -0
- package/dist/locations/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
- package/dist/locations/public-locations.d.ts.map +1 -0
- package/dist/locations/public-locations.js +41 -0
- package/dist/locations/public-locations.js.map +1 -0
- package/dist/options.d.ts +42 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +146 -0
- package/dist/options.js.map +1 -0
- package/dist/plugins/browser-console.d.ts +5 -4
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +47 -24
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/network.d.ts +24 -31
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +226 -229
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +4 -19
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js +6 -5
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +9 -5
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +46 -30
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +6 -6
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +13 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +35 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +131 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/push/index.d.ts +10 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +230 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/kibana_api.d.ts +56 -0
- package/dist/push/kibana_api.d.ts.map +1 -0
- package/dist/push/kibana_api.js +135 -0
- package/dist/push/kibana_api.js.map +1 -0
- package/dist/push/monitor.d.ts +55 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +277 -0
- package/dist/push/monitor.js.map +1 -0
- package/dist/{parse_args.d.ts → push/plugin.d.ts} +9 -6
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +66 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +45 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +109 -0
- package/dist/push/request.js.map +1 -0
- package/dist/push/utils.d.ts +45 -0
- package/dist/push/utils.d.ts.map +1 -0
- package/dist/push/utils.js +92 -0
- package/dist/push/utils.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +58 -50
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +17 -62
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +147 -177
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +90 -95
- package/dist/reporters/junit.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +35 -9
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
- package/dist/sdk/lh-trace-processor.js +114 -53
- package/dist/sdk/lh-trace-processor.js.map +1 -1
- package/dist/sdk/trace-metrics.d.ts +4 -4
- package/dist/sdk/trace-metrics.d.ts.map +1 -1
- package/dist/sdk/trace-metrics.js +3 -4
- package/dist/sdk/trace-metrics.js.map +1 -1
- package/dist/sdk/trace-processor.d.ts +11 -3
- package/dist/sdk/trace-processor.d.ts.map +1 -1
- package/dist/sdk/trace-processor.js +17 -9
- package/dist/sdk/trace-processor.js.map +1 -1
- package/package.json +38 -29
- package/src/cli.ts +225 -158
- package/src/common_types.ts +193 -34
- package/src/config.ts +1 -1
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +92 -25
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +8 -12
- package/src/core/runner.ts +158 -148
- package/src/core/transform.ts +160 -0
- package/src/dsl/journey.ts +40 -20
- package/src/dsl/monitor.ts +152 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +414 -0
- package/src/generator/index.ts +306 -0
- package/src/generator/utils.ts +84 -0
- package/src/helpers.ts +186 -16
- package/src/index.ts +22 -22
- package/src/loader.ts +171 -0
- package/src/locations/index.ts +95 -0
- package/src/{reporters/reporter.ts → locations/public-locations.ts} +12 -9
- package/src/options.ts +175 -0
- package/src/plugins/browser-console.ts +33 -8
- package/src/plugins/network.ts +266 -284
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +11 -9
- package/src/push/bundler.ts +112 -0
- package/src/push/index.ts +287 -0
- package/src/push/kibana_api.ts +191 -0
- package/src/push/monitor.ts +316 -0
- package/src/push/plugin.ts +66 -0
- package/src/push/request.ts +141 -0
- package/src/push/utils.ts +108 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +181 -201
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +8 -4
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +27 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/lightweight/heartbeat.yml +9 -0
- package/templates/synthetics.config.ts +35 -0
- package/CHANGELOG.md +0 -187
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -98
- package/dist/parse_args.js.map +0 -1
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1895
- package/src/parse_args.ts +0 -146
package/dist/helpers.js
CHANGED
|
@@ -27,19 +27,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.getDurationInUs = exports.CACHE_PATH = exports.formatError = exports.rewriteErrorStack = exports.rewriteErrorMessage = exports.findPWLogsIndexes = exports.totalist = exports.findPkgJsonByTraversing = exports.isFile = exports.isDirectory = exports.isDepInstalled = exports.runParallel = exports.now = exports.getTimestamp = exports.microSecsToSeconds = exports.monotonicTimeInSeconds = exports.generateTempPath = exports.generateUniqueId = exports.symbols = exports.indent = exports.noop =
|
|
30
|
+
exports.tagsMatch = exports.isMatch = exports.getProjectApiKeyURL = exports.getMonitorManagementURL = exports.removeTrailingSlash = exports.warn = exports.done = exports.error = exports.apiProgress = exports.liveProgress = exports.progress = exports.write = exports.safeNDJSONParse = exports.wrapFnWithLocation = exports.THROTTLING_WARNING_MSG = exports.getNetworkConditions = exports.DEFAULT_THROTTLING_OPTIONS = exports.megabitsToBytes = exports.getDurationInUs = exports.CACHE_PATH = exports.SYNTHETICS_PATH = exports.formatError = exports.rewriteErrorStack = exports.rewriteErrorMessage = exports.findPWLogsIndexes = exports.totalist = exports.findPkgJsonByTraversing = exports.isFile = exports.isDirectory = exports.isDepInstalled = exports.runParallel = exports.now = exports.getTimestamp = exports.microSecsToSeconds = exports.monotonicTimeInSeconds = exports.generateTempPath = exports.generateUniqueId = exports.symbols = exports.indent = exports.noop = void 0;
|
|
31
31
|
const colors_1 = require("kleur/colors");
|
|
32
32
|
const os_1 = __importDefault(require("os"));
|
|
33
33
|
const path_1 = require("path");
|
|
34
34
|
const fs_1 = __importDefault(require("fs"));
|
|
35
|
-
const
|
|
35
|
+
const promises_1 = require("fs/promises");
|
|
36
36
|
const perf_hooks_1 = require("perf_hooks");
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
exports.readFileAsync = util_1.promisify(fs_1.default.readFile);
|
|
40
|
-
exports.writeFileAsync = util_1.promisify(fs_1.default.writeFile);
|
|
41
|
-
exports.rmdirAsync = util_1.promisify(fs_1.default.rmdir);
|
|
42
|
-
exports.mkdirAsync = util_1.promisify(fs_1.default.mkdir);
|
|
37
|
+
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
38
|
+
const micromatch_1 = __importDefault(require("micromatch"));
|
|
43
39
|
const SEPARATOR = '\n';
|
|
44
40
|
function noop() { }
|
|
45
41
|
exports.noop = noop;
|
|
@@ -53,17 +49,18 @@ exports.indent = indent;
|
|
|
53
49
|
*/
|
|
54
50
|
const NO_UTF8_SUPPORT = process.platform === 'win32';
|
|
55
51
|
exports.symbols = {
|
|
56
|
-
warning: colors_1.yellow(NO_UTF8_SUPPORT ? '!' : '⚠'),
|
|
57
|
-
skipped: colors_1.cyan('-'),
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
warning: (0, colors_1.yellow)(NO_UTF8_SUPPORT ? '!' : '⚠'),
|
|
53
|
+
skipped: (0, colors_1.cyan)('-'),
|
|
54
|
+
progress: (0, colors_1.cyan)('>'),
|
|
55
|
+
succeeded: (0, colors_1.green)(NO_UTF8_SUPPORT ? 'ok' : '✓'),
|
|
56
|
+
failed: (0, colors_1.red)(NO_UTF8_SUPPORT ? 'x' : '✖'),
|
|
60
57
|
};
|
|
61
58
|
function generateUniqueId() {
|
|
62
59
|
return `${Date.now() + Math.floor(Math.random() * 1e13)}`;
|
|
63
60
|
}
|
|
64
61
|
exports.generateUniqueId = generateUniqueId;
|
|
65
62
|
function generateTempPath() {
|
|
66
|
-
return path_1.join(os_1.default.tmpdir(), `synthetics-${generateUniqueId()}`);
|
|
63
|
+
return (0, path_1.join)(os_1.default.tmpdir(), `synthetics-${generateUniqueId()}`);
|
|
67
64
|
}
|
|
68
65
|
exports.generateTempPath = generateTempPath;
|
|
69
66
|
/**
|
|
@@ -136,16 +133,16 @@ exports.isFile = isFile;
|
|
|
136
133
|
* from an NPM project.
|
|
137
134
|
*/
|
|
138
135
|
function findPkgJsonByTraversing(resolvePath, cwd) {
|
|
139
|
-
const packageJSON = path_1.resolve(resolvePath, 'package.json');
|
|
136
|
+
const packageJSON = (0, path_1.resolve)(resolvePath, 'package.json');
|
|
140
137
|
if (isFile(packageJSON)) {
|
|
141
138
|
return packageJSON;
|
|
142
139
|
}
|
|
143
|
-
const parentDirectory = path_1.dirname(resolvePath);
|
|
140
|
+
const parentDirectory = (0, path_1.dirname)(resolvePath);
|
|
144
141
|
/**
|
|
145
142
|
* We are in the system root and package.json does not exist
|
|
146
143
|
*/
|
|
147
144
|
if (resolvePath === parentDirectory) {
|
|
148
|
-
throw colors_1.red(`Could not find package.json file in: "${cwd}"\n` +
|
|
145
|
+
throw (0, colors_1.red)(`Could not find package.json file in: "${cwd}"\n` +
|
|
149
146
|
`It is recommended to run the agent in an NPM project.\n` +
|
|
150
147
|
`You can create one by running "npm init -y" in the project folder.`);
|
|
151
148
|
}
|
|
@@ -160,13 +157,13 @@ exports.findPkgJsonByTraversing = findPkgJsonByTraversing;
|
|
|
160
157
|
* https://github.com/lukeed/totalist/blob/44379974e535afe9c38e8d643dd64c59101a14b9/src/async.js#L8
|
|
161
158
|
*/
|
|
162
159
|
async function totalist(dir, callback, pre = '') {
|
|
163
|
-
dir = path_1.resolve('.', dir);
|
|
164
|
-
await
|
|
160
|
+
dir = (0, path_1.resolve)('.', dir);
|
|
161
|
+
await (0, promises_1.readdir)(dir).then(arr => {
|
|
165
162
|
return Promise.all(arr.map(str => {
|
|
166
|
-
const abs = path_1.join(dir, str);
|
|
167
|
-
return
|
|
168
|
-
? totalist(abs, callback, path_1.join(pre, str))
|
|
169
|
-
: callback(path_1.join(pre, str), abs));
|
|
163
|
+
const abs = (0, path_1.join)(dir, str);
|
|
164
|
+
return (0, promises_1.lstat)(abs).then(stats => stats.isDirectory()
|
|
165
|
+
? totalist(abs, callback, (0, path_1.join)(pre, str))
|
|
166
|
+
: callback((0, path_1.join)(pre, str), abs));
|
|
170
167
|
}));
|
|
171
168
|
});
|
|
172
169
|
}
|
|
@@ -221,10 +218,20 @@ function rewriteErrorStack(stack, indexes) {
|
|
|
221
218
|
return stack;
|
|
222
219
|
}
|
|
223
220
|
exports.rewriteErrorStack = rewriteErrorStack;
|
|
221
|
+
// formatError prefers receiving proper Errors, but since at runtime
|
|
222
|
+
// non Error exceptions can be thrown, it tolerates though. The
|
|
223
|
+
// redundant type Error | any expresses that.
|
|
224
224
|
function formatError(error) {
|
|
225
|
-
if (
|
|
225
|
+
if (error === undefined || error === null) {
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
+
if (!(error instanceof Error)) {
|
|
229
|
+
return {
|
|
230
|
+
message: `Error "${error}" received, with type "${typeof error}". (Do not throw exceptions without using \`new Error("my message")\`)`,
|
|
231
|
+
name: '',
|
|
232
|
+
stack: '',
|
|
233
|
+
};
|
|
234
|
+
}
|
|
228
235
|
const { name, message, stack } = error;
|
|
229
236
|
const indexes = findPWLogsIndexes(message);
|
|
230
237
|
return {
|
|
@@ -235,14 +242,157 @@ function formatError(error) {
|
|
|
235
242
|
}
|
|
236
243
|
exports.formatError = formatError;
|
|
237
244
|
const cwd = process.cwd();
|
|
245
|
+
/**
|
|
246
|
+
* All the settings that are related to the Synthetics is stored
|
|
247
|
+
* under this directory
|
|
248
|
+
* Examples: Screenshots, Project setup
|
|
249
|
+
*/
|
|
250
|
+
exports.SYNTHETICS_PATH = (0, path_1.join)(cwd, '.synthetics');
|
|
238
251
|
/**
|
|
239
252
|
* Synthetics cache path that is based on the process id to make sure
|
|
240
253
|
* each process does not modify the caching layer used by other process
|
|
241
254
|
* once we move to executing journeys in parallel
|
|
242
255
|
*/
|
|
243
|
-
exports.CACHE_PATH = path_1.join(
|
|
256
|
+
exports.CACHE_PATH = (0, path_1.join)(exports.SYNTHETICS_PATH, process.pid.toString());
|
|
244
257
|
function getDurationInUs(duration) {
|
|
245
258
|
return Math.trunc(duration * 1e6);
|
|
246
259
|
}
|
|
247
260
|
exports.getDurationInUs = getDurationInUs;
|
|
261
|
+
function megabitsToBytes(megabytes) {
|
|
262
|
+
return (megabytes * 1024 * 1024) / 8;
|
|
263
|
+
}
|
|
264
|
+
exports.megabitsToBytes = megabitsToBytes;
|
|
265
|
+
exports.DEFAULT_THROTTLING_OPTIONS = {
|
|
266
|
+
download: 5,
|
|
267
|
+
upload: 3,
|
|
268
|
+
latency: 20,
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Transforms the CLI throttling arguments in to format
|
|
272
|
+
* expected by Chrome devtools protocol NetworkConditions
|
|
273
|
+
*/
|
|
274
|
+
function getNetworkConditions(throttlingOpts) {
|
|
275
|
+
return {
|
|
276
|
+
downloadThroughput: megabitsToBytes(throttlingOpts.download),
|
|
277
|
+
uploadThroughput: megabitsToBytes(throttlingOpts.upload),
|
|
278
|
+
latency: throttlingOpts.latency,
|
|
279
|
+
offline: false,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
exports.getNetworkConditions = getNetworkConditions;
|
|
283
|
+
exports.THROTTLING_WARNING_MSG = `Throttling may not be active when the tests run - see
|
|
284
|
+
https://github.com/elastic/synthetics/blob/main/docs/throttling.md for more details`;
|
|
285
|
+
const dstackTraceLimit = 10;
|
|
286
|
+
// Uses the V8 Stacktrace API to get the function location
|
|
287
|
+
// information - https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
288
|
+
function wrapFnWithLocation(func) {
|
|
289
|
+
return (...args) => {
|
|
290
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
|
291
|
+
Error.prepareStackTrace = (_, stackFrames) => {
|
|
292
|
+
// Deafult CallSite would not map to the original transpiled source
|
|
293
|
+
// correctly, So we use source-map-support to map the CallSite to the
|
|
294
|
+
// original source from our cached source map
|
|
295
|
+
const frame = source_map_support_1.default.wrapCallSite(stackFrames[1]);
|
|
296
|
+
return {
|
|
297
|
+
file: frame.getFileName(),
|
|
298
|
+
line: frame.getLineNumber(),
|
|
299
|
+
column: frame.getColumnNumber(),
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
Error.stackTraceLimit = 2;
|
|
303
|
+
const obj = {};
|
|
304
|
+
Error.captureStackTrace(obj);
|
|
305
|
+
const location = obj.stack;
|
|
306
|
+
Error.stackTraceLimit = dstackTraceLimit;
|
|
307
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
308
|
+
return func(location, ...args);
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
exports.wrapFnWithLocation = wrapFnWithLocation;
|
|
312
|
+
// Safely parse ND JSON (Newline delimitted JSON) chunks
|
|
313
|
+
function safeNDJSONParse(data) {
|
|
314
|
+
// data may not be at proper newline boundaries, so we make sure everything is split
|
|
315
|
+
// on proper newlines
|
|
316
|
+
const chunks = Array.isArray(data) ? data : [data];
|
|
317
|
+
const lines = chunks.join('\n').split(/\r?\n/);
|
|
318
|
+
return lines
|
|
319
|
+
.filter(l => l.match(/\S/)) // remove blank lines
|
|
320
|
+
.map(line => {
|
|
321
|
+
try {
|
|
322
|
+
return JSON.parse(line);
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
throw `Error ${e} could not parse data '${line}'`;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
exports.safeNDJSONParse = safeNDJSONParse;
|
|
330
|
+
// Console helpers
|
|
331
|
+
function write(message, live) {
|
|
332
|
+
process.stderr.write(message + (live ? '\r' : '\n'));
|
|
333
|
+
}
|
|
334
|
+
exports.write = write;
|
|
335
|
+
function progress(message) {
|
|
336
|
+
write((0, colors_1.cyan)((0, colors_1.bold)(`${exports.symbols.progress} ${message}`)));
|
|
337
|
+
}
|
|
338
|
+
exports.progress = progress;
|
|
339
|
+
async function liveProgress(promise, message) {
|
|
340
|
+
const start = now();
|
|
341
|
+
const interval = setInterval(() => {
|
|
342
|
+
apiProgress(`${message} (${Math.trunc(now() - start)}ms)`, true);
|
|
343
|
+
}, 500);
|
|
344
|
+
promise.finally(() => clearInterval(interval));
|
|
345
|
+
const result = await promise;
|
|
346
|
+
apiProgress(`${message} (${Math.trunc(now() - start)}ms)`);
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
349
|
+
exports.liveProgress = liveProgress;
|
|
350
|
+
function apiProgress(message, live = false) {
|
|
351
|
+
write((0, colors_1.grey)(`> ${message}`), live);
|
|
352
|
+
}
|
|
353
|
+
exports.apiProgress = apiProgress;
|
|
354
|
+
function error(message) {
|
|
355
|
+
write((0, colors_1.red)(message));
|
|
356
|
+
}
|
|
357
|
+
exports.error = error;
|
|
358
|
+
function done(message) {
|
|
359
|
+
write((0, colors_1.bold)((0, colors_1.green)(`${exports.symbols['succeeded']} ${message}`)));
|
|
360
|
+
}
|
|
361
|
+
exports.done = done;
|
|
362
|
+
function warn(message) {
|
|
363
|
+
write((0, colors_1.bold)((0, colors_1.yellow)(`${exports.symbols['warning']} ${message}`)));
|
|
364
|
+
}
|
|
365
|
+
exports.warn = warn;
|
|
366
|
+
function removeTrailingSlash(url = '') {
|
|
367
|
+
return url.replace(/\/+$/, '');
|
|
368
|
+
}
|
|
369
|
+
exports.removeTrailingSlash = removeTrailingSlash;
|
|
370
|
+
function getMonitorManagementURL(url) {
|
|
371
|
+
return removeTrailingSlash(url) + '/app/synthetics/monitors';
|
|
372
|
+
}
|
|
373
|
+
exports.getMonitorManagementURL = getMonitorManagementURL;
|
|
374
|
+
function getProjectApiKeyURL(url) {
|
|
375
|
+
return removeTrailingSlash(url) + '/app/synthetics/settings/api-keys';
|
|
376
|
+
}
|
|
377
|
+
exports.getProjectApiKeyURL = getProjectApiKeyURL;
|
|
378
|
+
/**
|
|
379
|
+
* Matches tests based on the provided args. Proitize tags over match
|
|
380
|
+
* - tags pattern that matches only tags
|
|
381
|
+
* - match pattern that matches both name and tags
|
|
382
|
+
*/
|
|
383
|
+
function isMatch(tags, name, tagsPattern, matchPattern) {
|
|
384
|
+
if (tagsPattern) {
|
|
385
|
+
return tagsMatch(tags, tagsPattern);
|
|
386
|
+
}
|
|
387
|
+
if (matchPattern) {
|
|
388
|
+
return (micromatch_1.default.isMatch(name, matchPattern) || tagsMatch(tags, matchPattern));
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
exports.isMatch = isMatch;
|
|
393
|
+
function tagsMatch(tags, pattern) {
|
|
394
|
+
const matchess = (0, micromatch_1.default)(tags || ['*'], pattern);
|
|
395
|
+
return matchess.length > 0;
|
|
396
|
+
}
|
|
397
|
+
exports.tagsMatch = tagsMatch;
|
|
248
398
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,yCAAoE;AACpE,4CAAoB;AACpB,+BAA8C;AAC9C,4CAAoB;AACpB,0CAA6C;AAC7C,2CAAyC;AACzC,4EAAkD;AAQlD,4DAAoC;AAEpC,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,SAAgB,IAAI,KAAI,CAAC;AAAzB,oBAAyB;AAEzB,SAAgB,MAAM,CAAC,KAAa,EAAE,GAAG,GAAG,KAAK;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,wBAEC;AAED;;;GAGG;AACH,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACxC,QAAA,OAAO,GAAG;IACrB,OAAO,EAAE,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5C,OAAO,EAAE,IAAA,aAAI,EAAC,GAAG,CAAC;IAClB,QAAQ,EAAE,IAAA,aAAI,EAAC,GAAG,CAAC;IACnB,SAAS,EAAE,IAAA,cAAK,EAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9C,MAAM,EAAE,IAAA,YAAG,EAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;CACzC,CAAC;AAEF,SAAgB,gBAAgB;IAC9B,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IA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C,CAAC;KACrC;IACD,IAAI,YAAY,EAAE;QAChB,OAAO,CACL,oBAAU,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CACxE,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAfD,0BAeC;AAED,SAAgB,SAAS,CAAC,IAAI,EAAE,OAAO;IACrC,MAAM,QAAQ,GAAG,IAAA,oBAAU,EAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7B,CAAC;AAHD,8BAGC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,27 +22,25 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import { RunOptions } from './
|
|
25
|
+
import { RunOptions } from './common_types';
|
|
26
26
|
export declare function run(options: RunOptions): Promise<{
|
|
27
|
-
[x: string]:
|
|
28
|
-
status: import("./common_types").StatusValue;
|
|
29
|
-
error?: Error;
|
|
30
|
-
};
|
|
27
|
+
[x: string]: import("./common_types").JourneyResult;
|
|
31
28
|
}>;
|
|
32
29
|
/**
|
|
33
30
|
* Export all core module functions
|
|
34
31
|
*/
|
|
35
|
-
export {
|
|
32
|
+
export { journey, step, monitor, beforeAll, afterAll, before, after, } from './core';
|
|
36
33
|
export { expect } from './core/expect';
|
|
37
34
|
/**
|
|
38
35
|
* Export all the driver related types to be consumed
|
|
39
36
|
* and used by suites
|
|
40
37
|
*/
|
|
41
|
-
export type { Page, ChromiumBrowser, ChromiumBrowserContext, CDPSession, } from 'playwright-chromium';
|
|
38
|
+
export type { Page, ChromiumBrowser, ChromiumBrowserContext, CDPSession, APIRequestContext, } from 'playwright-chromium';
|
|
42
39
|
/**
|
|
43
40
|
* Export the types necessary to write custom reporters
|
|
44
41
|
*/
|
|
45
42
|
export type { default as Runner } from './core/runner';
|
|
46
43
|
export type { Reporter, ReporterOptions } from './reporters';
|
|
47
44
|
export type { SyntheticsConfig } from './common_types';
|
|
45
|
+
export type { Action, ActionInContext, FrameDescription, Signal, Step, Steps, actionTitle, } from './formatter/javascript';
|
|
48
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU;;GAE5C;AAED;;GAEG;AACH,OAAO,EACL,OAAO,EACP,IAAI,EACJ,OAAO,EACP,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,GACN,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC;;;GAGG;AACH,YAAY,EACV,IAAI,EACJ,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,YAAY,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,YAAY,EACV,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,GACZ,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,43 +23,22 @@
|
|
|
23
23
|
* THE SOFTWARE.
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.expect = exports.after = exports.before = exports.
|
|
27
|
+
exports.expect = exports.after = exports.before = exports.afterAll = exports.beforeAll = exports.monitor = exports.step = exports.journey = exports.run = void 0;
|
|
31
28
|
const core_1 = require("./core");
|
|
32
|
-
const logger_1 = require("./core/logger");
|
|
33
|
-
const source_map_support_1 = __importDefault(require("source-map-support"));
|
|
34
29
|
async function run(options) {
|
|
35
|
-
|
|
36
|
-
* Install source map support
|
|
37
|
-
*/
|
|
38
|
-
source_map_support_1.default.install({
|
|
39
|
-
environment: 'node',
|
|
40
|
-
});
|
|
41
|
-
/**
|
|
42
|
-
* set up logger with appropriate file descriptor
|
|
43
|
-
* to capture all the DEBUG logs when run through heartbeat
|
|
44
|
-
*/
|
|
45
|
-
logger_1.setLogger(options.outfd);
|
|
46
|
-
try {
|
|
47
|
-
return await core_1.runner.run(options);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.error('Failed to run the test', e);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
30
|
+
return core_1.runner.run(options);
|
|
53
31
|
}
|
|
54
32
|
exports.run = run;
|
|
55
33
|
/**
|
|
56
34
|
* Export all core module functions
|
|
57
35
|
*/
|
|
58
36
|
var core_2 = require("./core");
|
|
59
|
-
Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return core_2.beforeAll; } });
|
|
60
|
-
Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return core_2.afterAll; } });
|
|
61
37
|
Object.defineProperty(exports, "journey", { enumerable: true, get: function () { return core_2.journey; } });
|
|
62
38
|
Object.defineProperty(exports, "step", { enumerable: true, get: function () { return core_2.step; } });
|
|
39
|
+
Object.defineProperty(exports, "monitor", { enumerable: true, get: function () { return core_2.monitor; } });
|
|
40
|
+
Object.defineProperty(exports, "beforeAll", { enumerable: true, get: function () { return core_2.beforeAll; } });
|
|
41
|
+
Object.defineProperty(exports, "afterAll", { enumerable: true, get: function () { return core_2.afterAll; } });
|
|
63
42
|
Object.defineProperty(exports, "before", { enumerable: true, get: function () { return core_2.before; } });
|
|
64
43
|
Object.defineProperty(exports, "after", { enumerable: true, get: function () { return core_2.after; } });
|
|
65
44
|
var expect_1 = require("./core/expect");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,iCAAgC;AAGzB,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C,OAAO,aAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAFD,kBAEC;AAED;;GAEG;AACH,+BAQgB;AAPd,+FAAA,OAAO,OAAA;AACP,4FAAA,IAAI,OAAA;AACJ,+FAAA,OAAO,OAAA;AACP,iGAAA,SAAS,OAAA;AACT,gGAAA,QAAQ,OAAA;AACR,8FAAA,MAAM,OAAA;AACN,6FAAA,KAAK,OAAA;AAEP,wCAAuC;AAA9B,gGAAA,MAAM,OAAA"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
import { CliArgs } from './common_types';
|
|
26
|
+
/**
|
|
27
|
+
* Perform global setup process required for running the test suites
|
|
28
|
+
* and also for bundling the monitors. The process includes
|
|
29
|
+
* - Transpiling the TS/JS test files
|
|
30
|
+
* - Loading these files for running test suites
|
|
31
|
+
*/
|
|
32
|
+
export declare function globalSetup(options: CliArgs, args: string[]): Promise<() => void>;
|
|
33
|
+
export declare function loadTestFiles(options: CliArgs, args: string[]): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAezC;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,uBAMjE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBA0BnE"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.loadTestFiles = exports.globalSetup = void 0;
|
|
28
|
+
const process_1 = require("process");
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
const core_1 = require("./core");
|
|
31
|
+
const logger_1 = require("./core/logger");
|
|
32
|
+
const expect_1 = require("./core/expect");
|
|
33
|
+
const helpers_1 = require("./helpers");
|
|
34
|
+
const transform_1 = require("./core/transform");
|
|
35
|
+
const resolvedCwd = (0, process_1.cwd)();
|
|
36
|
+
const JOURNEY_EXTENSIONS = ['.js', '.ts', '.mjs', '.cjs'];
|
|
37
|
+
/**
|
|
38
|
+
* Perform global setup process required for running the test suites
|
|
39
|
+
* and also for bundling the monitors. The process includes
|
|
40
|
+
* - Transpiling the TS/JS test files
|
|
41
|
+
* - Loading these files for running test suites
|
|
42
|
+
*/
|
|
43
|
+
async function globalSetup(options, args) {
|
|
44
|
+
const revert = (0, transform_1.installTransform)();
|
|
45
|
+
await loadTestFiles(options, args);
|
|
46
|
+
return () => {
|
|
47
|
+
revert();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
exports.globalSetup = globalSetup;
|
|
51
|
+
async function loadTestFiles(options, args) {
|
|
52
|
+
/**
|
|
53
|
+
* Preload modules before running the tests
|
|
54
|
+
*/
|
|
55
|
+
const modules = [].concat(options.require || []).filter(Boolean);
|
|
56
|
+
for (const name of modules) {
|
|
57
|
+
if ((0, helpers_1.isDepInstalled)(name)) {
|
|
58
|
+
require(name);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error(`cannot find module '${name}'`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (options.inline) {
|
|
65
|
+
const source = await readStdin();
|
|
66
|
+
loadInlineScript(source);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handle piped files by reading the STDIN
|
|
71
|
+
* ex: ls example/suites/*.js | npx @elastic/synthetics
|
|
72
|
+
*/
|
|
73
|
+
const files = args.length > 0 ? args : (await readStdin()).split('\n').filter(Boolean);
|
|
74
|
+
const suites = await prepareSuites(files, options.pattern);
|
|
75
|
+
requireSuites(suites);
|
|
76
|
+
}
|
|
77
|
+
exports.loadTestFiles = loadTestFiles;
|
|
78
|
+
const loadInlineScript = source => {
|
|
79
|
+
const scriptFn = new Function('step', 'page', 'context', 'browser', 'params', 'expect', 'request', source);
|
|
80
|
+
(0, core_1.journey)('inline', ({ page, context, browser, params, request }) => {
|
|
81
|
+
scriptFn.apply(null, [
|
|
82
|
+
core_1.step,
|
|
83
|
+
page,
|
|
84
|
+
context,
|
|
85
|
+
browser,
|
|
86
|
+
params,
|
|
87
|
+
expect_1.expect,
|
|
88
|
+
request,
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Read the input from STDIN and run it as inline journey
|
|
94
|
+
*/
|
|
95
|
+
async function readStdin() {
|
|
96
|
+
const chunks = [];
|
|
97
|
+
process_1.stdin.resume();
|
|
98
|
+
process_1.stdin.setEncoding('utf-8');
|
|
99
|
+
for await (const chunk of process_1.stdin) {
|
|
100
|
+
chunks.push(chunk);
|
|
101
|
+
}
|
|
102
|
+
return chunks.join();
|
|
103
|
+
}
|
|
104
|
+
function requireSuites(suites) {
|
|
105
|
+
for (const suite of suites) {
|
|
106
|
+
require(suite);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Handle both directory and files that are passed through TTY
|
|
111
|
+
* and add them to suites
|
|
112
|
+
*/
|
|
113
|
+
async function prepareSuites(inputs, filePattern) {
|
|
114
|
+
const suites = new Set();
|
|
115
|
+
const addSuite = absPath => {
|
|
116
|
+
if (!JOURNEY_EXTENSIONS.includes((0, path_1.extname)(absPath))) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
(0, logger_1.log)(`Processing file: ${absPath}`);
|
|
120
|
+
suites.add(require.resolve(absPath));
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Match all files inside the directory with the
|
|
124
|
+
* .journey.{mjs|cjs|js|ts) extensions
|
|
125
|
+
*/
|
|
126
|
+
const pattern = filePattern
|
|
127
|
+
? new RegExp(filePattern, 'i')
|
|
128
|
+
: /.+\.journey\.([mc]js|[jt]s?)$/;
|
|
129
|
+
/**
|
|
130
|
+
* Ignore node_modules by default when running suites
|
|
131
|
+
*/
|
|
132
|
+
const ignored = /node_modules/i;
|
|
133
|
+
for (const input of inputs) {
|
|
134
|
+
const absPath = (0, path_1.resolve)(resolvedCwd, input);
|
|
135
|
+
/**
|
|
136
|
+
* Validate for package.json file before running
|
|
137
|
+
* the suites
|
|
138
|
+
*/
|
|
139
|
+
(0, helpers_1.findPkgJsonByTraversing)(absPath, resolvedCwd);
|
|
140
|
+
if ((0, helpers_1.isDirectory)(absPath)) {
|
|
141
|
+
await (0, helpers_1.totalist)(absPath, (rel, abs) => {
|
|
142
|
+
if (pattern.test(rel) && !ignored.test(rel)) {
|
|
143
|
+
addSuite(abs);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
addSuite(absPath);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return suites.values();
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,qCAAqC;AACrC,+BAAwC;AAExC,iCAAuC;AACvC,0CAAoC;AACpC,0CAAuC;AACvC,uCAKmB;AACnB,gDAAoD;AAEpD,MAAM,WAAW,GAAG,IAAA,aAAG,GAAE,CAAC;AAC1B,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1D;;;;;GAKG;AACI,KAAK,U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GG;IACH,MAAM,OAAO,GAAG,WAAW;QACzB,CAAC,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC;QAC9B,CAAC,CAAC,+BAA+B,CAAC;IACpC;;OAEG;IACH,MAAM,OAAO,GAAG,eAAe,CAAC;IAEhC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC5C;;;WAGG;QACH,IAAA,iCAAuB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC9C,IAAI,IAAA,qBAAW,EAAC,OAAO,CAAC,EAAE;YACxB,MAAM,IAAA,kBAAQ,EAAC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBACnC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;oBAC3C,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACf;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,QAAQ,CAAC,OAAO,CAAC,CAAC;SACnB;KACF;IACD,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export declare type LocationCmdOptions = {
|
|
26
|
+
auth: string;
|
|
27
|
+
url: string;
|
|
28
|
+
};
|
|
29
|
+
declare type LocationMetadata = {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
isServiceManaged: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare type LocationAPIResponse = {
|
|
35
|
+
locations: Array<LocationMetadata>;
|
|
36
|
+
};
|
|
37
|
+
export declare function getLocations(options: LocationCmdOptions): Promise<LocationMetadata[]>;
|
|
38
|
+
export declare function formatLocations(locations: Array<LocationMetadata>): string[];
|
|
39
|
+
export declare function groupLocations(locations: Array<string>): {
|
|
40
|
+
locations: any[];
|
|
41
|
+
privateLocations: any[];
|
|
42
|
+
};
|
|
43
|
+
export declare function renderLocations(locations: Array<string>): void;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,oBAAY,mBAAmB,GAAG;IAChC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;CACpC,CAAC;AAIF,wBAAsB,YAAY,CAAC,OAAO,EAAE,kBAAkB,+BAO7D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,YAajE;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC;;;EAUtD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,QAYvD"}
|