@elastic/synthetics 1.0.0-beta.8 → 1.0.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 +139 -165
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +158 -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 +32 -39
- 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 +241 -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 +36 -9
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +170 -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 +235 -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 +268 -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 +31 -0
- package/dist/push/utils.d.ts.map +1 -0
- package/dist/push/utils.js +64 -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 -30
- package/src/cli.ts +223 -158
- package/src/common_types.ts +191 -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 +41 -21
- 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 +308 -0
- package/src/generator/utils.ts +84 -0
- package/src/helpers.ts +182 -16
- package/src/index.ts +21 -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 +291 -0
- package/src/push/kibana_api.ts +191 -0
- package/src/push/monitor.ts +307 -0
- package/src/push/plugin.ts +66 -0
- package/src/push/request.ts +141 -0
- package/src/push/utils.ts +77 -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 -181
- 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/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,gCAAkE;AAClE,sDAA8B;AAE9B,qCAA+B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,gCAAkE;AAClE,sDAA8B;AAE9B,wCAAgD;AAChD,qCAA+B;AAG/B;;;GAGG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1D,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;IAC9B,MAAM,CAAC,iBAAiB,CAAC,GAAG,IAAI,gBAAM,EAAE,CAAC;CAC1C;AAEY,QAAA,MAAM,GAAW,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAE3C,QAAA,OAAO,GAAG,IAAA,4BAAkB,EACvC,CACE,QAAkB,EAClB,OAAgC,EAChC,QAAyB,EACzB,EAAE;IACF,IAAA,YAAG,EAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;KAC1C;IACD,MAAM,CAAC,GAAG,IAAI,aAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACnD,cAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,CAAC;AACX,CAAC,CACF,CAAC;AAEW,QAAA,IAAI,GAAG,IAAA,4BAAkB,EACpC,CAAC,QAAkB,EAAE,IAAY,EAAE,QAAsB,EAAE,EAAE;IAC3D,IAAA,YAAG,EAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IAC9B,OAAO,cAAM,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC,CACF,CAAC;AAEW,QAAA,OAAO,GAAG;IACrB,GAAG,EAAE,IAAA,4BAAkB,EAAC,CAAC,QAAkB,EAAE,MAAqB,EAAE,EAAE;QACpE;;;WAGG;QACH,IAAI,cAAM,CAAC,cAAc,EAAE;YACzB,cAAM,CAAC,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC7C;aAAM;YACL,cAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;CACH,CAAC;AAEK,MAAM,SAAS,GAAG,CAAC,QAAuB,EAAE,EAAE;IACnD,cAAM,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,QAAQ,GAAG,CAAC,QAAuB,EAAE,EAAE;IAClD,cAAM,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC,CAAC;AAFW,QAAA,QAAQ,YAEnB;AAEK,MAAM,MAAM,GAAG,CAAC,QAAuB,EAAE,EAAE;IAChD,IAAI,CAAC,cAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;IACD,OAAO,cAAM,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC3D,CAAC,CAAC;AALW,QAAA,MAAM,UAKjB;AAEK,MAAM,KAAK,GAAG,CAAC,QAAuB,EAAE,EAAE;IAC/C,IAAI,CAAC,cAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IACD,OAAO,cAAM,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC,CAAC;AALW,QAAA,KAAK,SAKhB"}
|
package/dist/core/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAYH,wBAAgB,GAAG,CAAC,GAAG,KAAA,QAStB"}
|
package/dist/core/logger.js
CHANGED
|
@@ -23,32 +23,25 @@
|
|
|
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.log =
|
|
31
|
-
const sonic_boom_1 = __importDefault(require("sonic-boom"));
|
|
27
|
+
exports.log = void 0;
|
|
32
28
|
const colors_1 = require("kleur/colors");
|
|
33
29
|
const helpers_1 = require("../helpers");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return logger;
|
|
41
|
-
};
|
|
42
|
-
exports.setLogger = setLogger;
|
|
30
|
+
/**
|
|
31
|
+
* Set debug based on DEBUG ENV and namespace - synthetics
|
|
32
|
+
*/
|
|
33
|
+
if (process.env.DEBUG && process.env.DEBUG.includes('synthetics')) {
|
|
34
|
+
process.env['__SYNTHETICS__DEBUG__'] = '1';
|
|
35
|
+
}
|
|
43
36
|
function log(msg) {
|
|
44
|
-
if (!process.env
|
|
37
|
+
if (!process.env['__SYNTHETICS__DEBUG__'] || !msg) {
|
|
45
38
|
return;
|
|
46
39
|
}
|
|
47
40
|
if (typeof msg === 'object') {
|
|
48
41
|
msg = JSON.stringify(msg);
|
|
49
42
|
}
|
|
50
|
-
const time = colors_1.dim(colors_1.cyan(`at ${parseInt(String(helpers_1.now()))} ms `));
|
|
51
|
-
|
|
43
|
+
const time = (0, colors_1.dim)((0, colors_1.cyan)(`at ${parseInt(String((0, helpers_1.now)()))} ms `));
|
|
44
|
+
process.stderr.write(time + (0, colors_1.italic)((0, colors_1.grey)(msg)) + '\n');
|
|
52
45
|
}
|
|
53
46
|
exports.log = log;
|
|
54
47
|
//# sourceMappingURL=logger.js.map
|
package/dist/core/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,yCAAuD;AACvD,wCAAiC;AAEjC;;GAEG;AACH,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;IACjE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,GAAG,GAAG,CAAC;CAC5C;AAED,SAAgB,GAAG,CAAC,GAAG;IACrB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE;QACjD,OAAO;KACR;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;KAC3B;IACD,MAAM,IAAI,GAAG,IAAA,YAAG,EAAC,IAAA,aAAI,EAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAA,aAAG,GAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAA,eAAM,EAAC,IAAA,aAAI,EAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACxD,CAAC;AATD,kBASC"}
|
package/dist/core/runner.d.ts
CHANGED
|
@@ -22,86 +22,34 @@
|
|
|
22
22
|
* THE SOFTWARE.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
/// <reference types="node" />
|
|
26
|
-
import { EventEmitter } from 'events';
|
|
27
25
|
import { Journey } from '../dsl/journey';
|
|
28
26
|
import { Step } from '../dsl/step';
|
|
29
|
-
import {
|
|
30
|
-
import { StatusValue, HooksCallback, Params, PluginOutput, CliArgs, HooksArgs, PlaywrightOptions } from '../common_types';
|
|
27
|
+
import { HooksCallback, Params, HooksArgs, Driver, RunOptions, JourneyResult, StepResult } from '../common_types';
|
|
31
28
|
import { PluginManager } from '../plugins';
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
export declare type
|
|
35
|
-
|
|
36
|
-
playwrightOptions?: PlaywrightOptions;
|
|
37
|
-
reporter?: CliArgs['reporter'] | Reporter;
|
|
38
|
-
};
|
|
39
|
-
declare type BaseContext = {
|
|
29
|
+
import { Monitor, MonitorConfig } from '../dsl/monitor';
|
|
30
|
+
declare type HookType = 'beforeAll' | 'afterAll';
|
|
31
|
+
export declare type SuiteHooks = Record<HookType, Array<HooksCallback>>;
|
|
32
|
+
declare type JourneyContext = {
|
|
40
33
|
params?: Params;
|
|
41
34
|
start: number;
|
|
42
|
-
end?: number;
|
|
43
|
-
};
|
|
44
|
-
declare type JourneyContext = BaseContext & {
|
|
45
35
|
driver: Driver;
|
|
46
36
|
pluginManager: PluginManager;
|
|
47
37
|
};
|
|
48
|
-
declare type StepResult = {
|
|
49
|
-
status: StatusValue;
|
|
50
|
-
url?: string;
|
|
51
|
-
metrics?: Metrics;
|
|
52
|
-
error?: Error;
|
|
53
|
-
};
|
|
54
|
-
declare type JourneyResult = {
|
|
55
|
-
status: StatusValue;
|
|
56
|
-
error?: Error;
|
|
57
|
-
};
|
|
58
38
|
declare type RunResult = Record<string, JourneyResult>;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
interface Events {
|
|
62
|
-
start: {
|
|
63
|
-
numJourneys: number;
|
|
64
|
-
};
|
|
65
|
-
'journey:register': {
|
|
66
|
-
journey: Journey;
|
|
67
|
-
};
|
|
68
|
-
'journey:start': {
|
|
69
|
-
journey: Journey;
|
|
70
|
-
timestamp: number;
|
|
71
|
-
params: Params;
|
|
72
|
-
};
|
|
73
|
-
'journey:end': BaseContext & JourneyResult & PluginOutput & {
|
|
74
|
-
journey: Journey;
|
|
75
|
-
options: RunOptions;
|
|
76
|
-
};
|
|
77
|
-
'journey:end:reported': unknown;
|
|
78
|
-
'step:start': {
|
|
79
|
-
journey: Journey;
|
|
80
|
-
step: Step;
|
|
81
|
-
};
|
|
82
|
-
'step:end': StepResult & {
|
|
83
|
-
start: number;
|
|
84
|
-
end: number;
|
|
85
|
-
journey: Journey;
|
|
86
|
-
step: Step;
|
|
87
|
-
};
|
|
88
|
-
end: unknown;
|
|
89
|
-
}
|
|
90
|
-
export default interface Runner {
|
|
91
|
-
on<K extends keyof Events>(name: K, listener: (v: Events[K]) => void): this;
|
|
92
|
-
emit<K extends keyof Events>(event: K, args: Events[K]): boolean;
|
|
93
|
-
}
|
|
94
|
-
export default class Runner extends EventEmitter {
|
|
95
|
-
active: boolean;
|
|
96
|
-
currentJourney?: Journey;
|
|
39
|
+
export default class Runner {
|
|
40
|
+
#private;
|
|
97
41
|
journeys: Journey[];
|
|
98
42
|
hooks: SuiteHooks;
|
|
99
43
|
hookError: Error | undefined;
|
|
44
|
+
monitor?: Monitor;
|
|
100
45
|
static screenshotPath: string;
|
|
101
46
|
static createContext(options: RunOptions): Promise<JourneyContext>;
|
|
102
47
|
captureScreenshot(page: Driver['page'], step: Step): Promise<void>;
|
|
48
|
+
get currentJourney(): Journey;
|
|
103
49
|
addHook(type: HookType, callback: HooksCallback): void;
|
|
50
|
+
updateMonitor(config: MonitorConfig): void;
|
|
104
51
|
addJourney(journey: Journey): void;
|
|
52
|
+
setReporter(options: RunOptions): void;
|
|
105
53
|
runBeforeAllHook(args: HooksArgs): Promise<void>;
|
|
106
54
|
runAfterAllHook(args: HooksArgs): Promise<void>;
|
|
107
55
|
runBeforeHook(journey: Journey, args: HooksArgs): Promise<void>;
|
|
@@ -116,6 +64,7 @@ export default class Runner extends EventEmitter {
|
|
|
116
64
|
runFakeJourney(journey: Journey, options: RunOptions): Promise<JourneyResult>;
|
|
117
65
|
runJourney(journey: Journey, options: RunOptions): Promise<JourneyResult>;
|
|
118
66
|
init(options: RunOptions): Promise<void>;
|
|
67
|
+
buildMonitors(options: RunOptions): Monitor[];
|
|
119
68
|
run(options: RunOptions): Promise<RunResult>;
|
|
120
69
|
reset(): Promise<void>;
|
|
121
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AASnC,OAAO,EACL,aAAa,EACb,MAAM,EACN,SAAS,EACT,MAAM,EAEN,UAAU,EACV,aAAa,EACb,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExD,aAAK,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;AACzC,oBAAY,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AAEhE,aAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAEF,aAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,MAAM;;IAIzB,QAAQ,EAAE,OAAO,EAAE,CAAM;IACzB,KAAK,EAAE,UAAU,CAAmC;IACpD,SAAS,EAAE,KAAK,GAAG,SAAS,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,cAAc,SAAmC;WAE3C,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IAqBlE,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI;IA4BxD,IAAI,cAAc,YAEjB;IAED,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa;IAI/C,aAAa,CAAC,MAAM,EAAE,aAAa;IAQnC,UAAU,CAAC,OAAO,EAAE,OAAO;IAK3B,WAAW,CAAC,OAAO,EAAE,UAAU;IAazB,gBAAgB,CAAC,IAAI,EAAE,SAAS;IAKhC,eAAe,CAAC,IAAI,EAAE,SAAS;IAK/B,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;IAK/C,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;IAK9C,OAAO,CACX,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,UAAU,CAAC;IAiEhB,QAAQ,CACZ,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,UAAU;IA8BrB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc;IAenD,UAAU,CACd,OAAO,KAAA,EACP,MAAM,EAAE,cAAc,GAAG,aAAa,EACtC,OAAO,EAAE,UAAU;IAmBrB;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU;IAoBpD,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU;IAiChD,IAAI,CAAC,OAAO,EAAE,UAAU;IAY9B,aAAa,CAAC,OAAO,EAAE,UAAU;IAgC3B,GAAG,CAAC,OAAO,EAAE,UAAU;IAuCvB,KAAK;CAWZ"}
|
package/dist/core/runner.js
CHANGED
|
@@ -24,30 +24,35 @@
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
const events_1 = require("events");
|
|
28
27
|
const path_1 = require("path");
|
|
28
|
+
const promises_1 = require("fs/promises");
|
|
29
29
|
const reporters_1 = require("../reporters");
|
|
30
30
|
const helpers_1 = require("../helpers");
|
|
31
|
-
const plugins_1 = require("../plugins");
|
|
32
31
|
const gatherer_1 = require("./gatherer");
|
|
33
32
|
const logger_1 = require("./logger");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const monitor_1 = require("../dsl/monitor");
|
|
34
|
+
class Runner {
|
|
35
|
+
#active = false;
|
|
36
|
+
#reporter;
|
|
37
|
+
#currentJourney = null;
|
|
38
|
+
journeys = [];
|
|
39
|
+
hooks = { beforeAll: [], afterAll: [] };
|
|
40
|
+
hookError;
|
|
41
|
+
monitor;
|
|
42
|
+
static screenshotPath = (0, path_1.join)(helpers_1.CACHE_PATH, 'screenshots');
|
|
42
43
|
static async createContext(options) {
|
|
43
|
-
const start = helpers_1.monotonicTimeInSeconds();
|
|
44
44
|
const driver = await gatherer_1.Gatherer.setupDriver(options);
|
|
45
|
+
/**
|
|
46
|
+
* Do not include browser launch/context creation duration
|
|
47
|
+
* as part of journey duration
|
|
48
|
+
*/
|
|
49
|
+
const start = (0, helpers_1.monotonicTimeInSeconds)();
|
|
45
50
|
const pluginManager = await gatherer_1.Gatherer.beginRecording(driver, options);
|
|
46
51
|
/**
|
|
47
52
|
* For each journey we create the screenshots folder for
|
|
48
53
|
* caching all screenshots and clear them at end of each journey
|
|
49
54
|
*/
|
|
50
|
-
await
|
|
55
|
+
await (0, promises_1.mkdir)(this.screenshotPath, { recursive: true });
|
|
51
56
|
return {
|
|
52
57
|
start,
|
|
53
58
|
params: options.params,
|
|
@@ -56,11 +61,11 @@ class Runner extends events_1.EventEmitter {
|
|
|
56
61
|
};
|
|
57
62
|
}
|
|
58
63
|
async captureScreenshot(page, step) {
|
|
59
|
-
await page.waitForLoadState('load');
|
|
60
64
|
const buffer = await page
|
|
61
65
|
.screenshot({
|
|
62
66
|
type: 'jpeg',
|
|
63
67
|
quality: 80,
|
|
68
|
+
timeout: 5000,
|
|
64
69
|
})
|
|
65
70
|
.catch(() => { });
|
|
66
71
|
/**
|
|
@@ -69,43 +74,66 @@ class Runner extends events_1.EventEmitter {
|
|
|
69
74
|
* each journey without impacting the step timing information
|
|
70
75
|
*/
|
|
71
76
|
if (buffer) {
|
|
72
|
-
const fileName = `${helpers_1.generateUniqueId()}.json`;
|
|
73
|
-
|
|
77
|
+
const fileName = `${(0, helpers_1.generateUniqueId)()}.json`;
|
|
78
|
+
const screenshot = {
|
|
74
79
|
step,
|
|
80
|
+
timestamp: (0, helpers_1.getTimestamp)(),
|
|
75
81
|
data: buffer.toString('base64'),
|
|
76
|
-
}
|
|
82
|
+
};
|
|
83
|
+
await (0, promises_1.writeFile)((0, path_1.join)(Runner.screenshotPath, fileName), JSON.stringify(screenshot));
|
|
84
|
+
(0, logger_1.log)(`Runner: captured screenshot for (${step.name})`);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
87
|
+
get currentJourney() {
|
|
88
|
+
return this.#currentJourney;
|
|
89
|
+
}
|
|
79
90
|
addHook(type, callback) {
|
|
80
91
|
this.hooks[type].push(callback);
|
|
81
92
|
}
|
|
93
|
+
updateMonitor(config) {
|
|
94
|
+
if (!this.monitor) {
|
|
95
|
+
this.monitor = new monitor_1.Monitor(config);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.monitor.update(config);
|
|
99
|
+
}
|
|
82
100
|
addJourney(journey) {
|
|
83
101
|
this.journeys.push(journey);
|
|
84
|
-
this
|
|
102
|
+
this.#currentJourney = journey;
|
|
103
|
+
}
|
|
104
|
+
setReporter(options) {
|
|
105
|
+
/**
|
|
106
|
+
* Set up the corresponding reporter and fallback
|
|
107
|
+
* to default reporter if not provided
|
|
108
|
+
*/
|
|
109
|
+
const { reporter, outfd } = options;
|
|
110
|
+
const Reporter = typeof reporter === 'function'
|
|
111
|
+
? reporter
|
|
112
|
+
: reporters_1.reporters[reporter] || reporters_1.reporters['default'];
|
|
113
|
+
this.#reporter = new Reporter({ fd: outfd });
|
|
85
114
|
}
|
|
86
115
|
async runBeforeAllHook(args) {
|
|
87
|
-
logger_1.log(`Runner: beforeAll hooks`);
|
|
88
|
-
await helpers_1.runParallel(this.hooks.beforeAll, args);
|
|
116
|
+
(0, logger_1.log)(`Runner: beforeAll hooks`);
|
|
117
|
+
await (0, helpers_1.runParallel)(this.hooks.beforeAll, args);
|
|
89
118
|
}
|
|
90
119
|
async runAfterAllHook(args) {
|
|
91
|
-
logger_1.log(`Runner: afterAll hooks`);
|
|
92
|
-
await helpers_1.runParallel(this.hooks.afterAll, args);
|
|
120
|
+
(0, logger_1.log)(`Runner: afterAll hooks`);
|
|
121
|
+
await (0, helpers_1.runParallel)(this.hooks.afterAll, args);
|
|
93
122
|
}
|
|
94
123
|
async runBeforeHook(journey, args) {
|
|
95
|
-
logger_1.log(`Runner: before hooks for (${journey.name})`);
|
|
96
|
-
await helpers_1.runParallel(journey.hooks.before, args);
|
|
124
|
+
(0, logger_1.log)(`Runner: before hooks for (${journey.name})`);
|
|
125
|
+
await (0, helpers_1.runParallel)(journey.hooks.before, args);
|
|
97
126
|
}
|
|
98
127
|
async runAfterHook(journey, args) {
|
|
99
|
-
logger_1.log(`Runner: after hooks for (${journey.name})`);
|
|
100
|
-
await helpers_1.runParallel(journey.hooks.after, args);
|
|
128
|
+
(0, logger_1.log)(`Runner: after hooks for (${journey.name})`);
|
|
129
|
+
await (0, helpers_1.runParallel)(journey.hooks.after, args);
|
|
101
130
|
}
|
|
102
131
|
async runStep(step, context, options) {
|
|
103
|
-
var _a;
|
|
104
132
|
const data = {
|
|
105
133
|
status: 'succeeded',
|
|
106
134
|
};
|
|
107
|
-
logger_1.log(`Runner: start step (${step.name})`);
|
|
108
|
-
const { metrics, screenshots } = options;
|
|
135
|
+
(0, logger_1.log)(`Runner: start step (${step.name})`);
|
|
136
|
+
const { metrics, screenshots, filmstrips, trace } = options;
|
|
109
137
|
const { driver, pluginManager } = context;
|
|
110
138
|
/**
|
|
111
139
|
* URL needs to be the first navigation request of any step
|
|
@@ -116,35 +144,59 @@ class Runner extends events_1.EventEmitter {
|
|
|
116
144
|
if (!data.url && req.isNavigationRequest()) {
|
|
117
145
|
data.url = req.url();
|
|
118
146
|
}
|
|
119
|
-
driver.
|
|
147
|
+
driver.context.off('request', captureUrl);
|
|
120
148
|
};
|
|
121
|
-
driver.
|
|
149
|
+
driver.context.on('request', captureUrl);
|
|
150
|
+
const traceEnabled = trace || filmstrips;
|
|
122
151
|
try {
|
|
152
|
+
/**
|
|
153
|
+
* Set up plugin manager context and also register
|
|
154
|
+
* step level plugins
|
|
155
|
+
*/
|
|
123
156
|
pluginManager.onStep(step);
|
|
157
|
+
traceEnabled && (await pluginManager.start('trace'));
|
|
158
|
+
// call the step definition
|
|
124
159
|
await step.callback();
|
|
125
|
-
if (metrics) {
|
|
126
|
-
data.metrics = await pluginManager.get(plugins_1.PerformanceManager).getMetrics();
|
|
127
|
-
}
|
|
128
160
|
}
|
|
129
161
|
catch (error) {
|
|
130
162
|
data.status = 'failed';
|
|
131
163
|
data.error = error;
|
|
132
164
|
}
|
|
133
165
|
finally {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Collect all step level metrics and trace events
|
|
168
|
+
*/
|
|
169
|
+
if (metrics) {
|
|
170
|
+
data.pagemetrics = await pluginManager.get('performance').getMetrics();
|
|
171
|
+
}
|
|
172
|
+
if (traceEnabled) {
|
|
173
|
+
const traceOutput = await pluginManager.stop('trace');
|
|
174
|
+
Object.assign(data, traceOutput);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Capture screenshot for the newly created pages
|
|
178
|
+
* via popup or new windows/tabs
|
|
179
|
+
*
|
|
180
|
+
* Last open page will get us the correct screenshot
|
|
181
|
+
*/
|
|
182
|
+
const pages = driver.context.pages();
|
|
183
|
+
const page = pages[pages.length - 1];
|
|
184
|
+
if (page) {
|
|
185
|
+
data.url ??= page.url();
|
|
186
|
+
if (screenshots && screenshots !== 'off') {
|
|
187
|
+
await this.captureScreenshot(page, step);
|
|
188
|
+
}
|
|
137
189
|
}
|
|
138
190
|
}
|
|
139
|
-
logger_1.log(`Runner: end step (${step.name})`);
|
|
191
|
+
(0, logger_1.log)(`Runner: end step (${step.name})`);
|
|
140
192
|
return data;
|
|
141
193
|
}
|
|
142
194
|
async runSteps(journey, context, options) {
|
|
143
195
|
const results = [];
|
|
144
196
|
let skipStep = false;
|
|
145
197
|
for (const step of journey.steps) {
|
|
146
|
-
const start = helpers_1.monotonicTimeInSeconds();
|
|
147
|
-
this
|
|
198
|
+
const start = (0, helpers_1.monotonicTimeInSeconds)();
|
|
199
|
+
this.#reporter?.onStepStart?.(journey, step);
|
|
148
200
|
let data = { status: 'succeeded' };
|
|
149
201
|
if (skipStep) {
|
|
150
202
|
data.status = 'skipped';
|
|
@@ -157,11 +209,9 @@ class Runner extends events_1.EventEmitter {
|
|
|
157
209
|
if (data.error)
|
|
158
210
|
skipStep = true;
|
|
159
211
|
}
|
|
160
|
-
this
|
|
161
|
-
journey,
|
|
162
|
-
step,
|
|
212
|
+
this.#reporter?.onStepEnd?.(journey, step, {
|
|
163
213
|
start,
|
|
164
|
-
end: helpers_1.monotonicTimeInSeconds(),
|
|
214
|
+
end: (0, helpers_1.monotonicTimeInSeconds)(),
|
|
165
215
|
...data,
|
|
166
216
|
});
|
|
167
217
|
if (options.pauseOnError && data.error) {
|
|
@@ -172,70 +222,62 @@ class Runner extends events_1.EventEmitter {
|
|
|
172
222
|
return results;
|
|
173
223
|
}
|
|
174
224
|
registerJourney(journey, context) {
|
|
175
|
-
this
|
|
176
|
-
const timestamp = helpers_1.getTimestamp();
|
|
225
|
+
this.#currentJourney = journey;
|
|
226
|
+
const timestamp = (0, helpers_1.getTimestamp)();
|
|
177
227
|
const { params } = context;
|
|
178
|
-
this
|
|
228
|
+
this.#reporter?.onJourneyStart?.(journey, {
|
|
229
|
+
timestamp,
|
|
230
|
+
params,
|
|
231
|
+
});
|
|
179
232
|
/**
|
|
180
|
-
*
|
|
233
|
+
* Exeucute the journey callback which would
|
|
234
|
+
* register the steps for the current journey
|
|
181
235
|
*/
|
|
182
236
|
journey.callback({ ...context.driver, params });
|
|
183
237
|
}
|
|
184
238
|
async endJourney(journey, result, options) {
|
|
239
|
+
const end = (0, helpers_1.monotonicTimeInSeconds)();
|
|
185
240
|
const { pluginManager, start, status, error } = result;
|
|
186
241
|
const pluginOutput = await pluginManager.output();
|
|
187
|
-
this
|
|
188
|
-
journey,
|
|
242
|
+
await this.#reporter?.onJourneyEnd?.(journey, {
|
|
189
243
|
status,
|
|
190
244
|
error,
|
|
191
245
|
start,
|
|
192
|
-
end
|
|
246
|
+
end,
|
|
247
|
+
timestamp: (0, helpers_1.getTimestamp)(),
|
|
193
248
|
options,
|
|
194
249
|
...pluginOutput,
|
|
195
250
|
browserconsole: status == 'failed' ? pluginOutput.browserconsole : [],
|
|
196
251
|
});
|
|
197
|
-
/**
|
|
198
|
-
* Wait for the all the reported events to be consumed aschronously
|
|
199
|
-
* by reporter.
|
|
200
|
-
*/
|
|
201
|
-
if (options.reporter === 'json') {
|
|
202
|
-
await events_1.once(this, 'journey:end:reported');
|
|
203
|
-
}
|
|
204
252
|
// clear screenshots cache after each journey
|
|
205
|
-
await
|
|
253
|
+
await (0, promises_1.rm)(Runner.screenshotPath, { recursive: true, force: true });
|
|
206
254
|
}
|
|
207
255
|
/**
|
|
208
256
|
* Simulate a journey run to capture errors in the beforeAll hook
|
|
209
257
|
*/
|
|
210
258
|
async runFakeJourney(journey, options) {
|
|
211
|
-
const start = helpers_1.monotonicTimeInSeconds();
|
|
212
|
-
this.
|
|
213
|
-
|
|
214
|
-
timestamp: helpers_1.getTimestamp(),
|
|
259
|
+
const start = (0, helpers_1.monotonicTimeInSeconds)();
|
|
260
|
+
this.#reporter.onJourneyStart?.(journey, {
|
|
261
|
+
timestamp: (0, helpers_1.getTimestamp)(),
|
|
215
262
|
params: options.params,
|
|
216
263
|
});
|
|
217
264
|
const result = {
|
|
218
265
|
status: 'failed',
|
|
219
266
|
error: this.hookError,
|
|
220
267
|
};
|
|
221
|
-
this.
|
|
222
|
-
|
|
268
|
+
await this.#reporter.onJourneyEnd?.(journey, {
|
|
269
|
+
timestamp: (0, helpers_1.getTimestamp)(),
|
|
223
270
|
start,
|
|
224
271
|
options,
|
|
225
|
-
end: helpers_1.monotonicTimeInSeconds(),
|
|
272
|
+
end: (0, helpers_1.monotonicTimeInSeconds)(),
|
|
226
273
|
...result,
|
|
227
274
|
});
|
|
228
|
-
if (options.reporter === 'json') {
|
|
229
|
-
await events_1.once(this, 'journey:end:reported');
|
|
230
|
-
}
|
|
231
275
|
return result;
|
|
232
276
|
}
|
|
233
277
|
async runJourney(journey, options) {
|
|
234
|
-
const result = {
|
|
235
|
-
status: 'succeeded',
|
|
236
|
-
};
|
|
237
|
-
logger_1.log(`Runner: start journey (${journey.name})`);
|
|
278
|
+
const result = { status: 'succeeded' };
|
|
238
279
|
const context = await Runner.createContext(options);
|
|
280
|
+
(0, logger_1.log)(`Runner: start journey (${journey.name})`);
|
|
239
281
|
try {
|
|
240
282
|
this.registerJourney(journey, context);
|
|
241
283
|
const hookArgs = {
|
|
@@ -263,31 +305,57 @@ class Runner extends events_1.EventEmitter {
|
|
|
263
305
|
await this.endJourney(journey, { ...context, ...result }, options);
|
|
264
306
|
await gatherer_1.Gatherer.dispose(context.driver);
|
|
265
307
|
}
|
|
266
|
-
logger_1.log(`Runner: end journey (${journey.name})`);
|
|
308
|
+
(0, logger_1.log)(`Runner: end journey (${journey.name})`);
|
|
267
309
|
return result;
|
|
268
310
|
}
|
|
269
311
|
async init(options) {
|
|
270
|
-
|
|
312
|
+
this.setReporter(options);
|
|
313
|
+
this.#reporter.onStart?.({
|
|
314
|
+
numJourneys: this.journeys.length,
|
|
315
|
+
networkConditions: options.networkConditions,
|
|
316
|
+
});
|
|
271
317
|
/**
|
|
272
|
-
* Set up the
|
|
318
|
+
* Set up the directory for caching screenshots
|
|
273
319
|
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
new Reporter(this, { fd: outfd });
|
|
278
|
-
this.emit('start', { numJourneys: this.journeys.length });
|
|
320
|
+
await (0, promises_1.mkdir)(helpers_1.CACHE_PATH, { recursive: true });
|
|
321
|
+
}
|
|
322
|
+
buildMonitors(options) {
|
|
279
323
|
/**
|
|
280
|
-
*
|
|
324
|
+
* Update the global monitor configuration required for
|
|
325
|
+
* setting defaults
|
|
281
326
|
*/
|
|
282
|
-
|
|
327
|
+
this.updateMonitor({
|
|
328
|
+
throttling: options.throttling,
|
|
329
|
+
schedule: options.schedule,
|
|
330
|
+
locations: options.locations,
|
|
331
|
+
privateLocations: options.privateLocations,
|
|
332
|
+
params: options.params,
|
|
333
|
+
playwrightOptions: options.playwrightOptions,
|
|
334
|
+
});
|
|
335
|
+
const monitors = [];
|
|
336
|
+
for (const journey of this.journeys) {
|
|
337
|
+
if (!journey.isMatch(options.match, options.tags)) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
this.#currentJourney = journey;
|
|
341
|
+
/**
|
|
342
|
+
* Execute dummy callback to get all monitor specific
|
|
343
|
+
* configurations for the current journey
|
|
344
|
+
*/
|
|
345
|
+
journey.callback({ params: options.params });
|
|
346
|
+
journey.monitor.update(this.monitor?.config);
|
|
347
|
+
journey.monitor.validate();
|
|
348
|
+
monitors.push(journey.monitor);
|
|
349
|
+
}
|
|
350
|
+
return monitors;
|
|
283
351
|
}
|
|
284
352
|
async run(options) {
|
|
285
353
|
const result = {};
|
|
286
|
-
if (this
|
|
354
|
+
if (this.#active) {
|
|
287
355
|
return result;
|
|
288
356
|
}
|
|
289
|
-
this
|
|
290
|
-
logger_1.log(`Runner: run ${this.journeys.length} journeys`);
|
|
357
|
+
this.#active = true;
|
|
358
|
+
(0, logger_1.log)(`Runner: run ${this.journeys.length} journeys`);
|
|
291
359
|
this.init(options);
|
|
292
360
|
await this.runBeforeAllHook({
|
|
293
361
|
env: options.environment,
|
|
@@ -299,7 +367,7 @@ class Runner extends events_1.EventEmitter {
|
|
|
299
367
|
* Used by heartbeat to gather all registered journeys
|
|
300
368
|
*/
|
|
301
369
|
if (dryRun) {
|
|
302
|
-
this.
|
|
370
|
+
this.#reporter.onJourneyRegister?.(journey);
|
|
303
371
|
continue;
|
|
304
372
|
}
|
|
305
373
|
if (!journey.isMatch(match, tags)) {
|
|
@@ -319,17 +387,16 @@ class Runner extends events_1.EventEmitter {
|
|
|
319
387
|
return result;
|
|
320
388
|
}
|
|
321
389
|
async reset() {
|
|
390
|
+
this.#currentJourney = null;
|
|
391
|
+
this.journeys = [];
|
|
392
|
+
this.#active = false;
|
|
322
393
|
/**
|
|
323
394
|
* Clear all cache data stored for post processing by
|
|
324
395
|
* the current synthetic agent run
|
|
325
396
|
*/
|
|
326
|
-
await
|
|
327
|
-
this
|
|
328
|
-
this.journeys = [];
|
|
329
|
-
this.active = false;
|
|
330
|
-
this.emit('end', {});
|
|
397
|
+
await (0, promises_1.rm)(helpers_1.CACHE_PATH, { recursive: true, force: true });
|
|
398
|
+
await this.#reporter?.onEnd?.();
|
|
331
399
|
}
|
|
332
400
|
}
|
|
333
401
|
exports.default = Runner;
|
|
334
|
-
Runner.screenshotPath = path_1.join(helpers_1.CACHE_PATH, 'screenshots');
|
|
335
402
|
//# sourceMappingURL=runner.js.map
|