@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.32
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 +4 -3
- package/dist/cli.js +123 -161
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +159 -34
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +2 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -5
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.js +5 -5
- 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 +4 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +49 -15
- 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 +3 -16
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +21 -65
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +212 -93
- 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 +9 -4
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +27 -7
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +66 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +63 -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 +2 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +98 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +295 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +29 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +240 -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 +80 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +24 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +126 -19
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +152 -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 +90 -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 +41 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +182 -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 +27 -8
- 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 +20 -33
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +173 -214
- 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 +5 -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 +44 -29
- 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 +8 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +123 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/push/index.d.ts +33 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +174 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +34 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +78 -0
- package/dist/push/monitor.js.map +1 -0
- package/{src/reporters/reporter.ts → dist/push/plugin.d.ts} +8 -10
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +133 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +43 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +83 -0
- package/dist/push/request.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 +54 -48
- 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 +18 -67
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +153 -175
- 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 +94 -89
- 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 +5 -6
- 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/dist/tsconfig.tsbuildinfo +1 -1888
- package/package.json +32 -20
- package/src/cli.ts +205 -152
- package/src/common_types.ts +192 -34
- package/src/config.ts +2 -5
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +59 -24
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +215 -152
- package/src/dsl/journey.ts +37 -6
- package/src/dsl/monitor.ts +88 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +367 -0
- package/src/generator/index.ts +316 -0
- package/src/generator/utils.ts +80 -0
- package/src/helpers.ts +132 -12
- package/src/index.ts +22 -22
- package/src/loader.ts +171 -0
- package/src/locations/index.ts +108 -0
- package/src/locations/public-locations.ts +38 -0
- package/src/options.ts +211 -0
- package/src/plugins/browser-console.ts +30 -8
- package/src/plugins/network.ts +208 -267
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +8 -9
- package/src/push/bundler.ts +100 -0
- package/src/push/index.ts +202 -0
- package/src/push/monitor.ts +96 -0
- package/src/push/plugin.ts +119 -0
- package/src/push/request.ts +103 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +203 -206
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +10 -6
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +26 -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/synthetics.config.ts +27 -0
- package/CHANGELOG.md +0 -102
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -89
- 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/src/parse_args.ts +0 -127
|
@@ -0,0 +1,80 @@
|
|
|
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.cloudIDToKibanaURL = exports.replaceTemplates = exports.runCommand = exports.getPackageManager = void 0;
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
async function getPackageManager(dir) {
|
|
31
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'yarn.lock'))) {
|
|
32
|
+
return 'yarn';
|
|
33
|
+
}
|
|
34
|
+
return 'npm';
|
|
35
|
+
}
|
|
36
|
+
exports.getPackageManager = getPackageManager;
|
|
37
|
+
function runCommand(pkgManager, command) {
|
|
38
|
+
if (pkgManager === 'yarn') {
|
|
39
|
+
return `yarn ${command}`;
|
|
40
|
+
}
|
|
41
|
+
return `npm run ${command}`;
|
|
42
|
+
}
|
|
43
|
+
exports.runCommand = runCommand;
|
|
44
|
+
function replaceTemplates(input, values) {
|
|
45
|
+
for (const key in values) {
|
|
46
|
+
const finalValue = values[key];
|
|
47
|
+
input = input.replace(new RegExp(`'{{` + key + `}}'`, 'g'), () => {
|
|
48
|
+
if (Array.isArray(finalValue)) {
|
|
49
|
+
return String(finalValue)
|
|
50
|
+
.split(',')
|
|
51
|
+
.map(f => `'${f}'`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof finalValue == 'number') {
|
|
54
|
+
return Number(finalValue);
|
|
55
|
+
}
|
|
56
|
+
return finalValue;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return input;
|
|
60
|
+
}
|
|
61
|
+
exports.replaceTemplates = replaceTemplates;
|
|
62
|
+
function cloudIDToKibanaURL(id) {
|
|
63
|
+
const ID_SEPARATOR = ':';
|
|
64
|
+
const VALUE_SEPARATOR = '$';
|
|
65
|
+
// Ignore values before the separator
|
|
66
|
+
const index = id.lastIndexOf(ID_SEPARATOR);
|
|
67
|
+
if (index >= 0) {
|
|
68
|
+
id = id.substring(index + 1);
|
|
69
|
+
}
|
|
70
|
+
// Decode the base64 string
|
|
71
|
+
const decoded = Buffer.from(id, 'base64').toString();
|
|
72
|
+
const words = decoded.split(VALUE_SEPARATOR);
|
|
73
|
+
// construct the kibana and ES urls from decoded value
|
|
74
|
+
const [host, port = '443'] = words[0].split(ID_SEPARATOR);
|
|
75
|
+
const [kibanaId, kibanaPort = port] = words[2].split(ID_SEPARATOR);
|
|
76
|
+
const kibanaURL = `https://${kibanaId}.${host}:${kibanaPort}`;
|
|
77
|
+
return kibanaURL;
|
|
78
|
+
}
|
|
79
|
+
exports.cloudIDToKibanaURL = cloudIDToKibanaURL;
|
|
80
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/generator/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,2BAAgC;AAChC,+BAA4B;AAErB,KAAK,UAAU,iBAAiB,CAAC,GAAW;IACjD,IAAI,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AALD,8CAKC;AAED,SAAgB,UAAU,CAAC,UAAkB,EAAE,OAAe;IAC5D,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,OAAO,QAAQ,OAAO,EAAE,CAAC;KAC1B;IACD,OAAO,WAAW,OAAO,EAAE,CAAC;AAC9B,CAAC;AALD,gCAKC;AAED,SAAgB,gBAAgB,CAAC,KAAa,EAAE,MAA2B;IACzE,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,K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K,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,WAAW,QAAQ,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;IAE9D,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,gDAmBC"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -22,15 +22,17 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
import { HooksArgs, HooksCallback } from './common_types';
|
|
25
|
+
import { HooksArgs, HooksCallback, NetworkConditions, Location, ThrottlingOptions } from './common_types';
|
|
26
26
|
export declare function noop(): void;
|
|
27
27
|
export declare function indent(lines: string, tab?: string): string;
|
|
28
28
|
export declare const symbols: {
|
|
29
29
|
warning: string;
|
|
30
30
|
skipped: string;
|
|
31
|
+
progress: string;
|
|
31
32
|
succeeded: string;
|
|
32
33
|
failed: string;
|
|
33
34
|
};
|
|
35
|
+
export declare function generateUniqueId(): string;
|
|
34
36
|
export declare function generateTempPath(): string;
|
|
35
37
|
/**
|
|
36
38
|
* Get Monotonically increasing time in seconds since
|
|
@@ -87,6 +89,12 @@ export declare function formatError(error: Error): {
|
|
|
87
89
|
message: string;
|
|
88
90
|
stack: string;
|
|
89
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* All the settings that are related to the Synthetics is stored
|
|
94
|
+
* under this directory
|
|
95
|
+
* Examples: Screenshots, Project setup
|
|
96
|
+
*/
|
|
97
|
+
export declare const SYNTHETICS_PATH: string;
|
|
90
98
|
/**
|
|
91
99
|
* Synthetics cache path that is based on the process id to make sure
|
|
92
100
|
* each process does not modify the caching layer used by other process
|
|
@@ -94,4 +102,19 @@ export declare function formatError(error: Error): {
|
|
|
94
102
|
*/
|
|
95
103
|
export declare const CACHE_PATH: string;
|
|
96
104
|
export declare function getDurationInUs(duration: number): number;
|
|
105
|
+
export declare function megabitsToBytes(megabytes: number): number;
|
|
106
|
+
export declare const DEFAULT_THROTTLING_OPTIONS: ThrottlingOptions;
|
|
107
|
+
/**
|
|
108
|
+
* Transforms the CLI throttling arguments in to format
|
|
109
|
+
* expected by Chrome devtools protocol NetworkConditions
|
|
110
|
+
*/
|
|
111
|
+
export declare function getNetworkConditions(throttlingOpts: ThrottlingOptions): NetworkConditions;
|
|
112
|
+
export declare function wrapFnWithLocation<A extends unknown[], R>(func: (location: Location, ...args: A) => R): (...args: A) => R;
|
|
113
|
+
export declare function safeNDJSONParse(chunks: string[]): any[];
|
|
114
|
+
export declare function write(message: string): void;
|
|
115
|
+
export declare function progress(message: string): void;
|
|
116
|
+
export declare function error(message: string): void;
|
|
117
|
+
export declare function done(message: string): void;
|
|
118
|
+
export declare function aborted(message: string): void;
|
|
119
|
+
export declare function removeTrailingSlash(url: string): string;
|
|
97
120
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,EACL,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAIxB,wBAAgB,IAAI,SAAK;AAEzB,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAQ,UAEhD;AAOD,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,wBAAgB,gBAAgB,WAE/B;AAED,wBAAgB,gBAAgB,WAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,WAGrC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,UAE5C;AAMD,wBAAgB,YAAY,WAE3B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CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EACvD,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAC1C,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAwBnB;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAc/C;AAGD,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,QAEpC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,QAEvC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,QAEpC;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,QAEnC;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,QAEtC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,UAE9C"}
|
package/dist/helpers.js
CHANGED
|
@@ -27,15 +27,14 @@ 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.symbols = exports.indent = exports.noop = void 0;
|
|
30
|
+
exports.removeTrailingSlash = exports.aborted = exports.done = exports.error = exports.progress = exports.write = exports.safeNDJSONParse = exports.wrapFnWithLocation = 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 readAsync = util_1.promisify(fs_1.default.readdir);
|
|
37
|
+
const source_map_support_1 = __importDefault(require("@cspotcode/source-map-support"));
|
|
39
38
|
const SEPARATOR = '\n';
|
|
40
39
|
function noop() { }
|
|
41
40
|
exports.noop = noop;
|
|
@@ -43,14 +42,24 @@ function indent(lines, tab = ' ') {
|
|
|
43
42
|
return lines.replace(/^/gm, tab);
|
|
44
43
|
}
|
|
45
44
|
exports.indent = indent;
|
|
45
|
+
/**
|
|
46
|
+
* Disable unicode symbols for windows, the underlying
|
|
47
|
+
* FS stream has a known issue in windows
|
|
48
|
+
*/
|
|
49
|
+
const NO_UTF8_SUPPORT = process.platform === 'win32';
|
|
46
50
|
exports.symbols = {
|
|
47
|
-
warning: colors_1.yellow('⚠'),
|
|
48
|
-
skipped: colors_1.cyan('-'),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
warning: (0, colors_1.yellow)(NO_UTF8_SUPPORT ? '!' : '⚠'),
|
|
52
|
+
skipped: (0, colors_1.cyan)('-'),
|
|
53
|
+
progress: (0, colors_1.cyan)('>'),
|
|
54
|
+
succeeded: (0, colors_1.green)(NO_UTF8_SUPPORT ? 'ok' : '✓'),
|
|
55
|
+
failed: (0, colors_1.red)(NO_UTF8_SUPPORT ? 'x' : '✖'),
|
|
51
56
|
};
|
|
57
|
+
function generateUniqueId() {
|
|
58
|
+
return `${Date.now() + Math.floor(Math.random() * 1e13)}`;
|
|
59
|
+
}
|
|
60
|
+
exports.generateUniqueId = generateUniqueId;
|
|
52
61
|
function generateTempPath() {
|
|
53
|
-
return path_1.join(os_1.default.tmpdir(), `synthetics-${
|
|
62
|
+
return (0, path_1.join)(os_1.default.tmpdir(), `synthetics-${generateUniqueId()}`);
|
|
54
63
|
}
|
|
55
64
|
exports.generateTempPath = generateTempPath;
|
|
56
65
|
/**
|
|
@@ -123,16 +132,16 @@ exports.isFile = isFile;
|
|
|
123
132
|
* from an NPM project.
|
|
124
133
|
*/
|
|
125
134
|
function findPkgJsonByTraversing(resolvePath, cwd) {
|
|
126
|
-
const packageJSON = path_1.resolve(resolvePath, 'package.json');
|
|
135
|
+
const packageJSON = (0, path_1.resolve)(resolvePath, 'package.json');
|
|
127
136
|
if (isFile(packageJSON)) {
|
|
128
137
|
return packageJSON;
|
|
129
138
|
}
|
|
130
|
-
const parentDirectory = path_1.dirname(resolvePath);
|
|
139
|
+
const parentDirectory = (0, path_1.dirname)(resolvePath);
|
|
131
140
|
/**
|
|
132
141
|
* We are in the system root and package.json does not exist
|
|
133
142
|
*/
|
|
134
143
|
if (resolvePath === parentDirectory) {
|
|
135
|
-
throw colors_1.red(`Could not find package.json file in: "${cwd}"\n` +
|
|
144
|
+
throw (0, colors_1.red)(`Could not find package.json file in: "${cwd}"\n` +
|
|
136
145
|
`It is recommended to run the agent in an NPM project.\n` +
|
|
137
146
|
`You can create one by running "npm init -y" in the project folder.`);
|
|
138
147
|
}
|
|
@@ -147,13 +156,13 @@ exports.findPkgJsonByTraversing = findPkgJsonByTraversing;
|
|
|
147
156
|
* https://github.com/lukeed/totalist/blob/44379974e535afe9c38e8d643dd64c59101a14b9/src/async.js#L8
|
|
148
157
|
*/
|
|
149
158
|
async function totalist(dir, callback, pre = '') {
|
|
150
|
-
dir = path_1.resolve('.', dir);
|
|
151
|
-
await
|
|
159
|
+
dir = (0, path_1.resolve)('.', dir);
|
|
160
|
+
await (0, promises_1.readdir)(dir).then(arr => {
|
|
152
161
|
return Promise.all(arr.map(str => {
|
|
153
|
-
const abs = path_1.join(dir, str);
|
|
154
|
-
return
|
|
155
|
-
? totalist(abs, callback, path_1.join(pre, str))
|
|
156
|
-
: callback(path_1.join(pre, str), abs));
|
|
162
|
+
const abs = (0, path_1.join)(dir, str);
|
|
163
|
+
return (0, promises_1.lstat)(abs).then(stats => stats.isDirectory()
|
|
164
|
+
? totalist(abs, callback, (0, path_1.join)(pre, str))
|
|
165
|
+
: callback((0, path_1.join)(pre, str), abs));
|
|
157
166
|
}));
|
|
158
167
|
});
|
|
159
168
|
}
|
|
@@ -222,14 +231,112 @@ function formatError(error) {
|
|
|
222
231
|
}
|
|
223
232
|
exports.formatError = formatError;
|
|
224
233
|
const cwd = process.cwd();
|
|
234
|
+
/**
|
|
235
|
+
* All the settings that are related to the Synthetics is stored
|
|
236
|
+
* under this directory
|
|
237
|
+
* Examples: Screenshots, Project setup
|
|
238
|
+
*/
|
|
239
|
+
exports.SYNTHETICS_PATH = (0, path_1.join)(cwd, '.synthetics');
|
|
225
240
|
/**
|
|
226
241
|
* Synthetics cache path that is based on the process id to make sure
|
|
227
242
|
* each process does not modify the caching layer used by other process
|
|
228
243
|
* once we move to executing journeys in parallel
|
|
229
244
|
*/
|
|
230
|
-
exports.CACHE_PATH = path_1.join(
|
|
245
|
+
exports.CACHE_PATH = (0, path_1.join)(exports.SYNTHETICS_PATH, process.pid.toString());
|
|
231
246
|
function getDurationInUs(duration) {
|
|
232
247
|
return Math.trunc(duration * 1e6);
|
|
233
248
|
}
|
|
234
249
|
exports.getDurationInUs = getDurationInUs;
|
|
250
|
+
function megabitsToBytes(megabytes) {
|
|
251
|
+
return (megabytes * 1024 * 1024) / 8;
|
|
252
|
+
}
|
|
253
|
+
exports.megabitsToBytes = megabitsToBytes;
|
|
254
|
+
exports.DEFAULT_THROTTLING_OPTIONS = {
|
|
255
|
+
download: 5,
|
|
256
|
+
upload: 3,
|
|
257
|
+
latency: 20,
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Transforms the CLI throttling arguments in to format
|
|
261
|
+
* expected by Chrome devtools protocol NetworkConditions
|
|
262
|
+
*/
|
|
263
|
+
function getNetworkConditions(throttlingOpts) {
|
|
264
|
+
return {
|
|
265
|
+
downloadThroughput: megabitsToBytes(throttlingOpts.download),
|
|
266
|
+
uploadThroughput: megabitsToBytes(throttlingOpts.upload),
|
|
267
|
+
latency: throttlingOpts.latency,
|
|
268
|
+
offline: false,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
exports.getNetworkConditions = getNetworkConditions;
|
|
272
|
+
const dstackTraceLimit = 10;
|
|
273
|
+
// Uses the V8 Stacktrace API to get the function location
|
|
274
|
+
// information - https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
275
|
+
function wrapFnWithLocation(func) {
|
|
276
|
+
return (...args) => {
|
|
277
|
+
const _prepareStackTrace = Error.prepareStackTrace;
|
|
278
|
+
Error.prepareStackTrace = (_, stackFrames) => {
|
|
279
|
+
// Deafult CallSite would not map to the original transpiled source
|
|
280
|
+
// from ts-node properly, So we wrap it with the library that knows
|
|
281
|
+
// how to retrive those source-map for the transpiled code
|
|
282
|
+
const frame = source_map_support_1.default.wrapCallSite(stackFrames[1]);
|
|
283
|
+
return {
|
|
284
|
+
file: frame.getFileName(),
|
|
285
|
+
line: frame.getLineNumber(),
|
|
286
|
+
column: frame.getColumnNumber(),
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
Error.stackTraceLimit = 2;
|
|
290
|
+
const obj = {};
|
|
291
|
+
Error.captureStackTrace(obj);
|
|
292
|
+
const location = obj.stack;
|
|
293
|
+
Error.stackTraceLimit = dstackTraceLimit;
|
|
294
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
295
|
+
return func(location, ...args);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
exports.wrapFnWithLocation = wrapFnWithLocation;
|
|
299
|
+
// Safely parse ND JSON (Newline delimitted JSON) chunks
|
|
300
|
+
function safeNDJSONParse(chunks) {
|
|
301
|
+
// chunks may not be at proper newline boundaries, so we make sure everything is split
|
|
302
|
+
// on proper newlines
|
|
303
|
+
chunks = Array.isArray(chunks) ? chunks : [chunks];
|
|
304
|
+
const lines = chunks.join('\n').split(/\r?\n/);
|
|
305
|
+
return lines
|
|
306
|
+
.filter(l => l.match(/\S/)) // remove blank lines
|
|
307
|
+
.map(line => {
|
|
308
|
+
try {
|
|
309
|
+
return JSON.parse(line);
|
|
310
|
+
}
|
|
311
|
+
catch (e) {
|
|
312
|
+
throw `Error ${e} could not parse data '${line}'`;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
exports.safeNDJSONParse = safeNDJSONParse;
|
|
317
|
+
// Console helpers
|
|
318
|
+
function write(message) {
|
|
319
|
+
process.stderr.write(message + '\n');
|
|
320
|
+
}
|
|
321
|
+
exports.write = write;
|
|
322
|
+
function progress(message) {
|
|
323
|
+
write((0, colors_1.cyan)((0, colors_1.bold)(`${exports.symbols.progress} ${message}`)));
|
|
324
|
+
}
|
|
325
|
+
exports.progress = progress;
|
|
326
|
+
function error(message) {
|
|
327
|
+
write((0, colors_1.red)(message));
|
|
328
|
+
}
|
|
329
|
+
exports.error = error;
|
|
330
|
+
function done(message) {
|
|
331
|
+
write((0, colors_1.bold)((0, colors_1.green)(`${exports.symbols['succeeded']} ${message}`)));
|
|
332
|
+
}
|
|
333
|
+
exports.done = done;
|
|
334
|
+
function aborted(message) {
|
|
335
|
+
write((0, colors_1.bold)((0, colors_1.yellow)(`${exports.symbols['warning']} ${message}`)));
|
|
336
|
+
}
|
|
337
|
+
exports.aborted = aborted;
|
|
338
|
+
function removeTrailingSlash(url) {
|
|
339
|
+
return url.replace(/\/+$/, '');
|
|
340
|
+
}
|
|
341
|
+
exports.removeTrailingSlash = removeTrailingSlash;
|
|
235
342
|
//# 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,yCAA8D;AAC9D,4CAAoB;AACpB,+BAA8C;AAC9C,4CAAoB;AACpB,0CAA6C;AAC7C,2CAAyC;AACzC,uFAA6D;AAS7D,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,IAAI,CAAC,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CAAC;AAdD,0CAcC;AAED,kBAAkB;AAClB,SAAgB,KAAK,CAAC,OAAe;IACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AACvC,CAAC;AAFD,sBAEC;AAED,SAAgB,QAAQ,CAAC,OAAe;IACtC,KAAK,CAAC,IAAA,aAAI,EAAC,IAAA,aAAI,EAAC,GAAG,eAAO,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,4BAEC;AAED,SAAgB,KAAK,CAAC,OAAe;IACnC,KAAK,CAAC,IAAA,YAAG,EAAC,OAAO,CAAC,CAAC,CAAC;AACtB,CAAC;AAFD,sBAEC;AAED,SAAgB,IAAI,CAAC,OAAe;IAClC,KAAK,CAAC,IAAA,aAAI,EAAC,IAAA,cAAK,EAAC,GAAG,eAAO,CAAC,WAAW,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,oBAEC;AAED,SAAgB,OAAO,CAAC,OAAe;IACrC,KAAK,CAAC,IAAA,aAAI,EAAC,IAAA,eAAM,EAAC,GAAG,eAAO,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,0BAEC;AAED,SAAgB,mBAAmB,CAAC,GAAW;IAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAFD,kDAEC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,26 +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';
|
|
44
|
+
export type { SyntheticsConfig } from './common_types';
|
|
45
|
+
export type { Action, ActionInContext, Signal, Step, Steps, actionTitle, } from './formatter/javascript';
|
|
47
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;AACvD,YAAY,EACV,MAAM,EACN,eAAe,EACf,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"}
|
|
@@ -23,8 +23,5 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
import { CliArgs } from './common_types';
|
|
26
|
-
declare
|
|
27
|
-
|
|
28
|
-
export { options };
|
|
29
|
-
export default command;
|
|
30
|
-
//# sourceMappingURL=parse_args.d.ts.map
|
|
26
|
+
export declare function loadTestFiles(options: CliArgs, args: string[]): Promise<void>;
|
|
27
|
+
//# 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;AAazC,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBA6CnE"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
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 = 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 resolvedCwd = (0, process_1.cwd)();
|
|
35
|
+
async function loadTestFiles(options, args) {
|
|
36
|
+
/**
|
|
37
|
+
* Transform `.ts` files out of the box by invoking
|
|
38
|
+
* the `ts-node` via `transpile-only` mode that compiles
|
|
39
|
+
* TS files without doing any extensive type checks.
|
|
40
|
+
*
|
|
41
|
+
* We must register `ts-node` _before_ loading inline
|
|
42
|
+
* scripts too because otherwise we will not be able to
|
|
43
|
+
* require `.ts` configuration files.
|
|
44
|
+
*/
|
|
45
|
+
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
|
|
46
|
+
require('ts-node').register({
|
|
47
|
+
transpileOnly: true,
|
|
48
|
+
compilerOptions: {
|
|
49
|
+
esModuleInterop: true,
|
|
50
|
+
allowJs: true,
|
|
51
|
+
target: 'es2020',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Preload modules before running the tests
|
|
56
|
+
*/
|
|
57
|
+
const modules = [].concat(options.require || []).filter(Boolean);
|
|
58
|
+
for (const name of modules) {
|
|
59
|
+
if ((0, helpers_1.isDepInstalled)(name)) {
|
|
60
|
+
require(name);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`cannot find module '${name}'`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (options.inline) {
|
|
67
|
+
const source = await readStdin();
|
|
68
|
+
loadInlineScript(source);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Handle piped files by reading the STDIN
|
|
73
|
+
* ex: ls example/suites/*.js | npx @elastic/synthetics
|
|
74
|
+
*/
|
|
75
|
+
const files = args.length > 0 ? args : (await readStdin()).split('\n').filter(Boolean);
|
|
76
|
+
const suites = await prepareSuites(files, options.pattern);
|
|
77
|
+
requireSuites(suites);
|
|
78
|
+
}
|
|
79
|
+
exports.loadTestFiles = loadTestFiles;
|
|
80
|
+
const loadInlineScript = source => {
|
|
81
|
+
const scriptFn = new Function('step', 'page', 'context', 'browser', 'params', 'expect', 'request', source);
|
|
82
|
+
(0, core_1.journey)('inline', ({ page, context, browser, params, request }) => {
|
|
83
|
+
scriptFn.apply(null, [
|
|
84
|
+
core_1.step,
|
|
85
|
+
page,
|
|
86
|
+
context,
|
|
87
|
+
browser,
|
|
88
|
+
params,
|
|
89
|
+
expect_1.expect,
|
|
90
|
+
request,
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Read the input from STDIN and run it as inline journey
|
|
96
|
+
*/
|
|
97
|
+
async function readStdin() {
|
|
98
|
+
const chunks = [];
|
|
99
|
+
process_1.stdin.resume();
|
|
100
|
+
process_1.stdin.setEncoding('utf-8');
|
|
101
|
+
for await (const chunk of process_1.stdin) {
|
|
102
|
+
chunks.push(chunk);
|
|
103
|
+
}
|
|
104
|
+
return chunks.join();
|
|
105
|
+
}
|
|
106
|
+
function requireSuites(suites) {
|
|
107
|
+
for (const suite of suites) {
|
|
108
|
+
require(suite);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Handle both directory and files that are passed through TTY
|
|
113
|
+
* and add them to suites
|
|
114
|
+
*/
|
|
115
|
+
async function prepareSuites(inputs, filePattern) {
|
|
116
|
+
const suites = new Set();
|
|
117
|
+
const addSuite = absPath => {
|
|
118
|
+
(0, logger_1.log)(`Processing file: ${absPath}`);
|
|
119
|
+
suites.add(require.resolve(absPath));
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Match all files inside the directory with the
|
|
123
|
+
* .journey.{mjs|cjs|js|ts) extensions
|
|
124
|
+
*/
|
|
125
|
+
const pattern = filePattern
|
|
126
|
+
? new RegExp(filePattern, 'i')
|
|
127
|
+
: /.+\.journey\.([mc]js|[jt]s?)$/;
|
|
128
|
+
/**
|
|
129
|
+
* Ignore node_modules by default when running suites
|
|
130
|
+
*/
|
|
131
|
+
const ignored = /node_modules/i;
|
|
132
|
+
for (const input of inputs) {
|
|
133
|
+
const absPath = (0, path_1.resolve)(resolvedCwd, input);
|
|
134
|
+
/**
|
|
135
|
+
* Validate for package.json file before running
|
|
136
|
+
* the suites
|
|
137
|
+
*/
|
|
138
|
+
(0, helpers_1.findPkgJsonByTraversing)(absPath, resolvedCwd);
|
|
139
|
+
if ((0, helpers_1.isDirectory)(absPath)) {
|
|
140
|
+
await (0, helpers_1.totalist)(absPath, (rel, abs) => {
|
|
141
|
+
if (pattern.test(rel) && !ignored.test(rel)) {
|
|
142
|
+
addSuite(abs);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
addSuite(absPath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return suites.values();
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=loader.js.map
|