@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.30

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.
Files changed (189) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +99 -162
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +156 -34
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/config.d.ts +2 -5
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +5 -5
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/browser-service.js +5 -5
  11. package/dist/core/browser-service.js.map +1 -1
  12. package/dist/core/gatherer.d.ts +4 -8
  13. package/dist/core/gatherer.d.ts.map +1 -1
  14. package/dist/core/gatherer.js +46 -14
  15. package/dist/core/gatherer.js.map +1 -1
  16. package/dist/core/index.d.ts +5 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +23 -11
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/logger.d.ts +0 -1
  21. package/dist/core/logger.d.ts.map +1 -1
  22. package/dist/core/logger.js +3 -16
  23. package/dist/core/logger.js.map +1 -1
  24. package/dist/core/runner.d.ts +21 -65
  25. package/dist/core/runner.d.ts.map +1 -1
  26. package/dist/core/runner.js +211 -93
  27. package/dist/core/runner.js.map +1 -1
  28. package/dist/dsl/journey.d.ts +7 -3
  29. package/dist/dsl/journey.d.ts.map +1 -1
  30. package/dist/dsl/journey.js +22 -6
  31. package/dist/dsl/journey.js.map +1 -1
  32. package/{src/reporters/reporter.ts → dist/dsl/locations.d.ts} +12 -10
  33. package/dist/dsl/locations.d.ts.map +1 -0
  34. package/dist/dsl/locations.js +41 -0
  35. package/dist/dsl/locations.js.map +1 -0
  36. package/dist/dsl/monitor.d.ts +65 -0
  37. package/dist/dsl/monitor.d.ts.map +1 -0
  38. package/dist/dsl/monitor.js +63 -0
  39. package/dist/dsl/monitor.js.map +1 -0
  40. package/dist/dsl/step.d.ts +3 -2
  41. package/dist/dsl/step.d.ts.map +1 -1
  42. package/dist/dsl/step.js +2 -1
  43. package/dist/dsl/step.js.map +1 -1
  44. package/dist/formatter/javascript.d.ts +98 -0
  45. package/dist/formatter/javascript.d.ts.map +1 -0
  46. package/dist/formatter/javascript.js +295 -0
  47. package/dist/formatter/javascript.js.map +1 -0
  48. package/dist/generator/index.d.ts +21 -0
  49. package/dist/generator/index.d.ts.map +1 -0
  50. package/dist/generator/index.js +169 -0
  51. package/dist/generator/index.js.map +1 -0
  52. package/dist/{reporters/reporter.d.ts → generator/utils.d.ts} +4 -9
  53. package/dist/generator/utils.d.ts.map +1 -0
  54. package/dist/generator/utils.js +57 -0
  55. package/dist/generator/utils.js.map +1 -0
  56. package/dist/helpers.d.ts +20 -1
  57. package/dist/helpers.d.ts.map +1 -1
  58. package/dist/helpers.js +98 -18
  59. package/dist/helpers.js.map +1 -1
  60. package/dist/index.d.ts +5 -6
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +5 -26
  63. package/dist/index.js.map +1 -1
  64. package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
  65. package/dist/loader.d.ts.map +1 -0
  66. package/dist/loader.js +144 -0
  67. package/dist/loader.js.map +1 -0
  68. package/dist/options.d.ts +34 -0
  69. package/dist/options.d.ts.map +1 -0
  70. package/dist/options.js +162 -0
  71. package/dist/options.js.map +1 -0
  72. package/dist/plugins/browser-console.d.ts +5 -4
  73. package/dist/plugins/browser-console.d.ts.map +1 -1
  74. package/dist/plugins/browser-console.js +27 -8
  75. package/dist/plugins/browser-console.js.map +1 -1
  76. package/dist/plugins/network.d.ts +20 -33
  77. package/dist/plugins/network.d.ts.map +1 -1
  78. package/dist/plugins/network.js +173 -214
  79. package/dist/plugins/network.js.map +1 -1
  80. package/dist/plugins/performance.d.ts +4 -19
  81. package/dist/plugins/performance.d.ts.map +1 -1
  82. package/dist/plugins/performance.js +5 -5
  83. package/dist/plugins/performance.js.map +1 -1
  84. package/dist/plugins/plugin-manager.d.ts +9 -5
  85. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  86. package/dist/plugins/plugin-manager.js +44 -29
  87. package/dist/plugins/plugin-manager.js.map +1 -1
  88. package/dist/plugins/tracing.d.ts +6 -6
  89. package/dist/plugins/tracing.d.ts.map +1 -1
  90. package/dist/plugins/tracing.js +8 -7
  91. package/dist/plugins/tracing.js.map +1 -1
  92. package/dist/push/bundler.d.ts +34 -0
  93. package/dist/push/bundler.d.ts.map +1 -0
  94. package/dist/push/bundler.js +114 -0
  95. package/dist/push/bundler.js.map +1 -0
  96. package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
  97. package/dist/push/index.d.ts.map +1 -0
  98. package/dist/push/index.js +55 -0
  99. package/dist/push/index.js.map +1 -0
  100. package/dist/push/monitor.d.ts +32 -0
  101. package/dist/push/monitor.d.ts.map +1 -0
  102. package/dist/push/monitor.js +62 -0
  103. package/dist/push/monitor.js.map +1 -0
  104. package/dist/push/plugin.d.ts +33 -0
  105. package/dist/push/plugin.d.ts.map +1 -0
  106. package/dist/push/plugin.js +124 -0
  107. package/dist/push/plugin.js.map +1 -0
  108. package/dist/push/request.d.ts +42 -0
  109. package/dist/push/request.d.ts.map +1 -0
  110. package/dist/push/request.js +84 -0
  111. package/dist/push/request.js.map +1 -0
  112. package/dist/reporters/base.d.ts +14 -6
  113. package/dist/reporters/base.d.ts.map +1 -1
  114. package/dist/reporters/base.js +54 -48
  115. package/dist/reporters/base.js.map +1 -1
  116. package/dist/reporters/index.d.ts +18 -8
  117. package/dist/reporters/index.d.ts.map +1 -1
  118. package/dist/reporters/index.js.map +1 -1
  119. package/dist/reporters/json.d.ts +18 -67
  120. package/dist/reporters/json.d.ts.map +1 -1
  121. package/dist/reporters/json.js +153 -175
  122. package/dist/reporters/json.js.map +1 -1
  123. package/dist/reporters/junit.d.ts +7 -1
  124. package/dist/reporters/junit.d.ts.map +1 -1
  125. package/dist/reporters/junit.js +94 -89
  126. package/dist/reporters/junit.js.map +1 -1
  127. package/dist/sdk/lh-trace-processor.d.ts +35 -9
  128. package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
  129. package/dist/sdk/lh-trace-processor.js +114 -53
  130. package/dist/sdk/lh-trace-processor.js.map +1 -1
  131. package/dist/sdk/trace-metrics.d.ts +4 -4
  132. package/dist/sdk/trace-metrics.d.ts.map +1 -1
  133. package/dist/sdk/trace-metrics.js +5 -6
  134. package/dist/sdk/trace-metrics.js.map +1 -1
  135. package/dist/sdk/trace-processor.d.ts +11 -3
  136. package/dist/sdk/trace-processor.d.ts.map +1 -1
  137. package/dist/sdk/trace-processor.js +17 -9
  138. package/dist/sdk/trace-processor.js.map +1 -1
  139. package/dist/tsconfig.tsbuildinfo +1 -1888
  140. package/package.json +31 -19
  141. package/src/cli.ts +187 -154
  142. package/src/common_types.ts +188 -34
  143. package/src/config.ts +2 -5
  144. package/src/core/gatherer.ts +55 -27
  145. package/src/core/index.ts +36 -15
  146. package/src/core/logger.ts +1 -12
  147. package/src/core/runner.ts +216 -152
  148. package/src/dsl/journey.ts +29 -5
  149. package/src/dsl/locations.ts +38 -0
  150. package/src/dsl/monitor.ts +87 -0
  151. package/src/dsl/step.ts +9 -2
  152. package/src/formatter/javascript.ts +367 -0
  153. package/src/generator/index.ts +212 -0
  154. package/src/generator/utils.ts +54 -0
  155. package/src/helpers.ts +106 -10
  156. package/src/index.ts +21 -22
  157. package/src/loader.ts +162 -0
  158. package/src/options.ts +173 -0
  159. package/src/plugins/browser-console.ts +30 -8
  160. package/src/plugins/network.ts +208 -267
  161. package/src/plugins/performance.ts +6 -22
  162. package/src/plugins/plugin-manager.ts +49 -31
  163. package/src/plugins/tracing.ts +8 -9
  164. package/src/push/bundler.ts +95 -0
  165. package/src/push/index.ts +59 -0
  166. package/src/push/monitor.ts +68 -0
  167. package/src/push/plugin.ts +114 -0
  168. package/src/push/request.ts +111 -0
  169. package/src/reporters/base.ts +63 -52
  170. package/src/reporters/index.ts +26 -3
  171. package/src/reporters/json.ts +203 -206
  172. package/src/reporters/junit.ts +98 -93
  173. package/src/sdk/lh-trace-processor.ts +132 -68
  174. package/src/sdk/trace-metrics.ts +10 -6
  175. package/src/sdk/trace-processor.ts +28 -13
  176. package/templates/.github/workflows/run-synthetics.yml +26 -0
  177. package/templates/README.md +21 -0
  178. package/templates/journeys/advanced-example-helpers.ts +54 -0
  179. package/templates/journeys/advanced-example.journey.ts +43 -0
  180. package/templates/journeys/example.journey.ts +18 -0
  181. package/templates/synthetics.config.ts +26 -0
  182. package/CHANGELOG.md +0 -102
  183. package/NOTICE.txt +0 -221
  184. package/dist/parse_args.d.ts.map +0 -1
  185. package/dist/parse_args.js +0 -89
  186. package/dist/parse_args.js.map +0 -1
  187. package/dist/reporters/reporter.d.ts.map +0 -1
  188. package/dist/reporters/reporter.js.map +0 -1
  189. package/src/parse_args.ts +0 -127
package/dist/config.js CHANGED
@@ -53,10 +53,10 @@ function readConfig(env, config) {
53
53
  }
54
54
  exports.readConfig = readConfig;
55
55
  function resolveConfigPath(configPath, cwd) {
56
- const absolutePath = path_1.isAbsolute(configPath)
56
+ const absolutePath = (0, path_1.isAbsolute)(configPath)
57
57
  ? configPath
58
- : path_1.resolve(cwd, configPath);
59
- if (helpers_1.isFile(absolutePath)) {
58
+ : (0, path_1.resolve)(cwd, configPath);
59
+ if ((0, helpers_1.isFile)(absolutePath)) {
60
60
  return absolutePath;
61
61
  }
62
62
  throw new Error('Synthetics config file does not exist: ' + absolutePath);
@@ -79,12 +79,12 @@ function getConfigFile(ext) {
79
79
  }
80
80
  function findSyntheticsConfig(resolvePath, cwd) {
81
81
  const configPath = ['.js', '.ts']
82
- .map(ext => path_1.resolve(resolvePath, getConfigFile(ext)))
82
+ .map(ext => (0, path_1.resolve)(resolvePath, getConfigFile(ext)))
83
83
  .find(helpers_1.isFile);
84
84
  if (configPath) {
85
85
  return configPath;
86
86
  }
87
- const parentDirectory = path_1.dirname(resolvePath);
87
+ const parentDirectory = (0, path_1.dirname)(resolvePath);
88
88
  /**
89
89
  * We are in the system root, so return empty path and fallback
90
90
  * to empty suite params
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,+BAAoD;AACpD,uCAAmC;AAMnC,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAe;IACrD,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClD,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;KAC1C;SAAM;QACL;;;WAGG;QACH,MAAM,UAAU,GAAG,oBAAoB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClD,UAAU,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC;KAC1D;IACD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;QACjC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;KACxB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAtBD,gCAsBC;AAED,SAAS,iBAAiB,CAAC,UAAkB,EAAE,GAAW;IACxD,MAAM,YAAY,GAAG,iBAAU,CAAC,UAAU,CAAC;QACzC,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,cAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAE7B,IAAI,gBAAM,CAAC,YAAY,CAAC,EAAE;QACxB,OAAO,YAAY,CAAC;KACrB;IACD,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,YAAY,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAQ;IACrC,OAAO,GAAG,IAAI,GAAG,CA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GAAG,UAAU,CAAC,CAAC;KACpE;AACH,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,mBAAmB,GAAG,GAAG,CAAC;AACnC,CAAC;AAED,SAAS,oBAAoB,CAAC,WAAW,EAAE,GAAG;IAC5C,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC;SAC9B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAA,cAAO,EAAC,WAAW,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;SACpD,IAAI,CAAC,gBAAM,CAAC,CAAC;IAChB,IAAI,UAAU,EAAE;QACd,OAAO,UAAU,CAAC;KACnB;IACD,MAAM,eAAe,GAAG,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC;IAC7C;;;OAGG;IACH,IAAI,WAAW,KAAK,eAAe,EAAE;QACnC,OAAO,EAAE,CAAC;KACX;IACD,OAAO,oBAAoB,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC"}
@@ -34,16 +34,16 @@ class BrowserService {
34
34
  constructor(options = { port: 9322 }) {
35
35
  this.options = options;
36
36
  this.closeCallbacks = [];
37
- this.proxyServer = http_1.createServer();
37
+ this.proxyServer = (0, http_1.createServer)();
38
38
  }
39
39
  init() {
40
- const proxy = http_proxy_1.createProxyServer();
40
+ const proxy = (0, http_proxy_1.createProxyServer)();
41
41
  this.proxyServer.on('upgrade', async (req, socket, head) => {
42
42
  const browserServer = await playwright_chromium_1.chromium.launchServer({ headless: true });
43
43
  const wsEndpoint = browserServer.wsEndpoint();
44
44
  const { pathname, origin } = new url_1.URL(wsEndpoint);
45
45
  req.url = pathname;
46
- logger_1.log(`New browser: ${wsEndpoint}`);
46
+ (0, logger_1.log)(`New browser: ${wsEndpoint}`);
47
47
  proxy.ws(req, socket, head, { target: origin });
48
48
  const closeBrowser = async () => {
49
49
  const index = this.closeCallbacks.indexOf(closeBrowser);
@@ -51,14 +51,14 @@ class BrowserService {
51
51
  this.closeCallbacks.splice(index, 1);
52
52
  }
53
53
  await browserServer.close();
54
- logger_1.log(`Socket closed: ${wsEndpoint}`);
54
+ (0, logger_1.log)(`Socket closed: ${wsEndpoint}`);
55
55
  };
56
56
  this.closeCallbacks.push(closeBrowser);
57
57
  socket.on('close', closeBrowser);
58
58
  socket.on('error', closeBrowser);
59
59
  });
60
60
  this.proxyServer.listen(this.options.port, () => {
61
- logger_1.log(`Listening on port: ${this.options.port}`);
61
+ (0, logger_1.log)(`Listening on port: ${this.options.port}`);
62
62
  });
63
63
  }
64
64
  async dispose() {
@@ -1 +1 @@
1
- {"version":3,"file":"browser-service.js","sourceRoot":"","sources":["../../src/core/browser-service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,6BAA0B;AAC1B,+BAAoC;AACpC,2CAA+C;AAC/C,6DAA+C;AAC/C,qCAA+B;AAE/B,MAAa,cAAc;IAIzB,YAAoB,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAH5C,mBAAc,GAAG,EAAE,CAAC;QACpB,gBAAW,GAAG,mBAAY,EAAE,CAAC;IAEkB,CAAC;IAEhD,IAAI;QACF,MAAM,KAAK,GAAG,8BAAiB,EAAE,CAAC;QAElC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACzD,MAAM,aAAa,GAAG,MAAM,8BAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACtE,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,EAAE,CAAC;YAC9C,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,SAAG,CAAC,UAAU,CAAC,CAAC;YACjD,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC;YACnB,YAAG,CAAC,gBAAgB,UAAU,EAAE,CA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AAI,CAAC,EAAE;oBACd,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;iBACtC;gBACD,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC5B,IAAA,YAAG,EAAC,kBAAkB,UAAU,EAAE,CAAC,CAAC;YACtC,CAAC,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACjC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;YAC9C,IAAA,YAAG,EAAC,sBAAsB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YACxC,MAAM,QAAQ,EAAE,CAAC;SAClB;QACD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QAEzB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,wCA6CC"}
@@ -22,15 +22,9 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { CDPSession, ChromiumBrowser, ChromiumBrowserContext, Page } from 'playwright-chromium';
25
+ import { ChromiumBrowser, BrowserContext } from 'playwright-chromium';
26
26
  import { PluginManager } from '../plugins';
27
- import { RunOptions } from './runner';
28
- export declare type Driver = {
29
- browser: ChromiumBrowser;
30
- context: ChromiumBrowserContext;
31
- page: Page;
32
- client: CDPSession;
33
- };
27
+ import { Driver, NetworkConditions, RunOptions } from '../common_types';
34
28
  /**
35
29
  * Purpose of the Gatherer is to set up the necessary browser driver
36
30
  * related capabilities for the runner to run all journeys
@@ -38,6 +32,8 @@ export declare type Driver = {
38
32
  export declare class Gatherer {
39
33
  static browser: ChromiumBrowser;
40
34
  static setupDriver(options: RunOptions): Promise<Driver>;
35
+ static getUserAgent(userAgent?: string): Promise<string>;
36
+ static setNetworkConditions(context: BrowserContext, networkConditions: NetworkConditions): void;
41
37
  /**
42
38
  * Starts recording all events related to the v8 devtools protocol
43
39
  * https://chromedevtools.github.io/devtools-protocol/v8/
@@ -1 +1 @@
1
- {"version":3,"file":"gatherer.d.ts","sourceRoot":"","sources":["../../src/core/gatherer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,UAAU,EAEV,eAAe,EACf,sBAAsB,EACtB,IAAI,EACL,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,oBAAY,MAAM,GAAG;IACnB,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,sBAAsB,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,qBAAa,QAAQ;IACnB,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC;WAEnB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB9D;;;OAGG;WACU,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;WAclD,OAAO,CAAC,MAAM,EAAE,MAAM;WAItB,IAAI;CAMlB"}
1
+ {"version":3,"file":"gatherer.d.ts","sourceRoot":"","sources":["../../src/core/gatherer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAY,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;GAGG;AACH,qBAAa,QAAQ;IACnB,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC;WAEnB,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;WA6BjD,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM;IAS5C,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,cAAc,EACvB,iBAAiB,EAAE,iBAAiB;IAsBtC;;;OAGG;WACU,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;WAYlD,OAAO,CAAC,MAAM,EAAE,MAAM;WAItB,IAAI;CAMlB"}
@@ -34,38 +34,70 @@ const logger_1 = require("./logger");
34
34
  */
35
35
  class Gatherer {
36
36
  static async setupDriver(options) {
37
+ (0, logger_1.log)('Gatherer: setup driver');
38
+ const { wsEndpoint, playwrightOptions, networkConditions } = options;
37
39
  if (Gatherer.browser == null) {
38
- const { wsEndpoint, headless, sandbox = false } = options;
39
40
  if (wsEndpoint) {
40
- logger_1.log(`Gatherer: connecting to WS endpoint: ${wsEndpoint}`);
41
- Gatherer.browser = await playwright_chromium_1.chromium.connect({ wsEndpoint });
41
+ (0, logger_1.log)(`Gatherer: connecting to WS endpoint: ${wsEndpoint}`);
42
+ Gatherer.browser = await playwright_chromium_1.chromium.connect(wsEndpoint);
42
43
  }
43
44
  else {
44
45
  Gatherer.browser = await playwright_chromium_1.chromium.launch({
45
- headless,
46
- chromiumSandbox: sandbox,
46
+ ...playwrightOptions,
47
+ args: [
48
+ ...(playwrightOptions?.headless ? ['--disable-gpu'] : []),
49
+ ...(playwrightOptions?.args ?? []),
50
+ ],
47
51
  });
48
52
  }
49
53
  }
50
- const context = await Gatherer.browser.newContext();
54
+ const context = await Gatherer.browser.newContext({
55
+ ...playwrightOptions,
56
+ userAgent: await Gatherer.getUserAgent(playwrightOptions?.userAgent),
57
+ });
58
+ Gatherer.setNetworkConditions(context, networkConditions);
51
59
  const page = await context.newPage();
52
60
  const client = await context.newCDPSession(page);
53
61
  return { browser: Gatherer.browser, context, page, client };
54
62
  }
63
+ static async getUserAgent(userAgent) {
64
+ if (!userAgent) {
65
+ const session = await Gatherer.browser.newBrowserCDPSession();
66
+ ({ userAgent } = await session.send('Browser.getVersion'));
67
+ return userAgent + ' Elastic/Synthetics';
68
+ }
69
+ return userAgent;
70
+ }
71
+ static setNetworkConditions(context, networkConditions) {
72
+ if (networkConditions) {
73
+ context.on('page', page => {
74
+ const context = page.context();
75
+ const emulatePromise = context
76
+ .newCDPSession(page)
77
+ .then(client => client.send('Network.emulateNetworkConditions', networkConditions));
78
+ /**
79
+ * Guard against pages that gets closed before the emulation kicks to capture
80
+ * unhandled rejections from accessing the CDP session of closed page
81
+ */
82
+ Promise.race([
83
+ new Promise(resolve => page.on('close', () => resolve())),
84
+ emulatePromise,
85
+ ]);
86
+ });
87
+ }
88
+ }
55
89
  /**
56
90
  * Starts recording all events related to the v8 devtools protocol
57
91
  * https://chromedevtools.github.io/devtools-protocol/v8/
58
92
  */
59
93
  static async beginRecording(driver, options) {
60
- logger_1.log('Gatherer: started recording');
61
- const { filmstrips, trace, network, metrics } = options;
94
+ (0, logger_1.log)('Gatherer: started recording');
95
+ const { network, metrics } = options;
62
96
  const pluginManager = new plugins_1.PluginManager(driver);
63
- const plugins = [pluginManager.start('browserconsole')];
64
- network && plugins.push(pluginManager.start('network'));
65
- metrics && plugins.push(pluginManager.start('performance'));
66
- if (filmstrips || trace) {
67
- plugins.push(pluginManager.start('trace', { filmstrips, trace }));
68
- }
97
+ pluginManager.registerAll(options);
98
+ const plugins = [await pluginManager.start('browserconsole')];
99
+ network && plugins.push(await pluginManager.start('network'));
100
+ metrics && plugins.push(await pluginManager.start('performance'));
69
101
  await Promise.all(plugins);
70
102
  return pluginManager;
71
103
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gatherer.js","sourceRoot":"","sources":["../../src/core/gatherer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,6DAM6B;AAC7B,wCAA2C;AAE3C,qCAA+B;AAS/B;;;GAGG;AACH,MAAa,QAAQ;IAGnB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAmB;QAC1C,IAAI,QAAQ,CAAC,OAAO,IAAI,IAAI,EAAE;YAC5B,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;YAC1D,IAAI,UAAU,EAAE;gBACd,YAAG,CAAC,wCAAwC,UAAU,EAAE,CAAC,CAAC;gBAC1D,QAAQ,CAAC,OAAO,GAAG,MAAM,8BAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;aAC3D;iBAAM;gBACL,QAAQ,CAAC,OAAO,GAAG,MAAM,8BAAQ,CAAC,MAAM,CAAC;oBACvC,QAAQ;oBACR,eAAe,EAAE,OAAO;iBACzB,CAAC,CAAC;aACJ;SACF;QACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC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AC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;QAClE,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAc;QACjC,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,MAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC/B,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;SACzB;IACH,CAAC;CACF;AA3FD,4BA2FC"}
@@ -25,9 +25,13 @@
25
25
  import { Journey, JourneyCallback, JourneyOptions } from '../dsl';
26
26
  import Runner from './runner';
27
27
  import { VoidCallback, HooksCallback } from '../common_types';
28
+ import { MonitorConfig } from '../dsl/monitor';
28
29
  export declare const runner: Runner;
29
- export declare const journey: (options: JourneyOptions | string, callback: JourneyCallback) => Journey;
30
+ export declare const journey: (options: string | JourneyOptions, callback: JourneyCallback) => Journey;
30
31
  export declare const step: (name: string, callback: VoidCallback) => import("../dsl").Step;
32
+ export declare const monitor: {
33
+ use: (config: MonitorConfig) => void;
34
+ };
31
35
  export declare const beforeAll: (callback: HooksCallback) => void;
32
36
  export declare const afterAll: (callback: HooksCallback) => void;
33
37
  export declare const before: (callback: HooksCallback) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","s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F,eAAO,MAAM,MAAM,aAAc,aAAa,SAK7C,CAAC;AAEF,eAAO,MAAM,KAAK,aAAc,aAAa,SAK5C,CAAC"}
@@ -27,9 +27,10 @@ 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.after = exports.before = exports.afterAll = exports.beforeAll = exports.step = exports.journey = exports.runner = void 0;
30
+ exports.after = exports.before = exports.afterAll = exports.beforeAll = exports.monitor = exports.step = exports.journey = exports.runner = void 0;
31
31
  const dsl_1 = require("../dsl");
32
32
  const runner_1 = __importDefault(require("./runner"));
33
+ const helpers_1 = require("../helpers");
33
34
  const logger_1 = require("./logger");
34
35
  /**
35
36
  * Use a gloabl Runner which would be accessed by the runtime and
@@ -40,22 +41,33 @@ if (!global[SYNTHETICS_RUNNER]) {
40
41
  global[SYNTHETICS_RUNNER] = new runner_1.default();
41
42
  }
42
43
  exports.runner = global[SYNTHETICS_RUNNER];
43
- const journey = (options, callback) => {
44
- logger_1.log(`register journey: ${options}`);
44
+ exports.journey = (0, helpers_1.wrapFnWithLocation)((location, options, callback) => {
45
+ (0, logger_1.log)(`register journey: ${JSON.stringify(options)}`);
45
46
  if (typeof options === 'string') {
46
47
  options = { name: options, id: options };
47
48
  }
48
- const j = new dsl_1.Journey(options, callback);
49
+ const j = new dsl_1.Journey(options, callback, location);
49
50
  exports.runner.addJourney(j);
50
51
  return j;
52
+ });
53
+ exports.step = (0, helpers_1.wrapFnWithLocation)((location, name, callback) => {
54
+ (0, logger_1.log)(`register step: ${name}`);
55
+ return exports.runner.currentJourney?.addStep(name, callback, location);
56
+ });
57
+ exports.monitor = {
58
+ use: (0, helpers_1.wrapFnWithLocation)((location, config) => {
59
+ /**
60
+ * If the context is inside journey, then set it to journey context
61
+ * otherwise set to the global monitor which will be used for all journeys
62
+ */
63
+ if (exports.runner.currentJourney) {
64
+ exports.runner.currentJourney.updateMonitor(config);
65
+ }
66
+ else {
67
+ exports.runner.updateMonitor(config);
68
+ }
69
+ }),
51
70
  };
52
- exports.journey = journey;
53
- const step = (name, callback) => {
54
- var _a;
55
- logger_1.log(`register step: ${name}`);
56
- return (_a = exports.runner.currentJourney) === null || _a === void 0 ? void 0 : _a.addStep(name, callback);
57
- };
58
- exports.step = step;
59
71
  const beforeAll = (callback) => {
60
72
  exports.runner.addHook('beforeAll', callback);
61
73
  };
@@ -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;AAE/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;AAEjD,MAAM,OAAO,GAAG,CACrB,OAAgC,EAChC,QAAyB,EACzB,EAAE;IACF,YAAG,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;IACpC,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,CAAC,CAAC;IACzC,cAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AAXW,QAAA,OAAO,WAWlB;AAEK,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,QAAsB,EAAE,EAAE;;IAC3D,YAAG,CAAC,kBAAkB,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,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"}
@@ -22,6 +22,5 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- export declare const setLogger: (fd: number) => any;
26
25
  export declare function log(msg: any): void;
27
26
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,eAAO,MAAM,SAAS,OAAQ,MAAM,QAKnC,CAAC;AAEF,wBAAgB,GAAG,CAAC,GAAG,KAAA,QAStB"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wBAAgB,GAAG,CAAC,GAAG,KAAA,QAStB"}
@@ -23,23 +23,10 @@
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 = exports.setLogger = void 0;
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
- const defaultFd = process.stdout.fd;
35
- let logger = new sonic_boom_1.default({ fd: defaultFd, sync: true });
36
- const setLogger = (fd) => {
37
- if (fd && fd !== defaultFd) {
38
- logger = new sonic_boom_1.default({ fd });
39
- }
40
- return logger;
41
- };
42
- exports.setLogger = setLogger;
43
30
  function log(msg) {
44
31
  if (!process.env.DEBUG || !msg) {
45
32
  return;
@@ -47,8 +34,8 @@ function log(msg) {
47
34
  if (typeof msg === 'object') {
48
35
  msg = JSON.stringify(msg);
49
36
  }
50
- const time = colors_1.dim(colors_1.cyan(`at ${parseInt(String(helpers_1.now()))} ms `));
51
- logger.write(time + colors_1.italic(colors_1.grey(msg)) + '\n');
37
+ const time = (0, colors_1.dim)((0, colors_1.cyan)(`at ${parseInt(String((0, helpers_1.now)()))} ms `));
38
+ console.log(time + (0, colors_1.italic)((0, colors_1.grey)(msg)) + '\n');
52
39
  }
53
40
  exports.log = log;
54
41
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,4DAAmC;AACnC,yCA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AAG,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,GAAG,CAAC,IAAI,GAAG,IAAA,eAAM,EAAC,IAAA,aAAI,EAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC/C,CAAC;AATD,kBASC"}
@@ -22,83 +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 { Reporter } from '../reporters';
30
- import { StatusValue, HooksCallback, Params, PluginOutput, CliArgs, HooksArgs } from '../common_types';
27
+ import { HooksCallback, Params, HooksArgs, Driver, RunOptions, JourneyResult, StepResult } from '../common_types';
31
28
  import { PluginManager } from '../plugins';
32
- import { Metrics } from '../plugins';
33
- import { Driver } from './gatherer';
34
- export declare type RunOptions = Omit<CliArgs, 'debug' | 'json' | 'pattern' | 'inline' | 'require' | 'suiteParams' | 'reporter' | 'richEvents' | 'capability'> & {
35
- params?: Params;
36
- reporter?: CliArgs['reporter'] | Reporter;
37
- };
38
- 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 = {
39
33
  params?: Params;
40
34
  start: number;
41
- end?: number;
42
- };
43
- declare type JourneyContext = BaseContext & {
44
35
  driver: Driver;
45
36
  pluginManager: PluginManager;
46
37
  };
47
- declare type StepResult = {
48
- status: StatusValue;
49
- url?: string;
50
- metrics?: Metrics;
51
- error?: Error;
52
- };
53
- declare type JourneyResult = {
54
- status: StatusValue;
55
- error?: Error;
56
- };
57
38
  declare type RunResult = Record<string, JourneyResult>;
58
- declare type HookType = 'beforeAll' | 'afterAll';
59
- export declare type SuiteHooks = Record<HookType, Array<HooksCallback>>;
60
- interface Events {
61
- start: {
62
- numJourneys: number;
63
- };
64
- 'journey:register': {
65
- journey: Journey;
66
- };
67
- 'journey:start': {
68
- journey: Journey;
69
- timestamp: number;
70
- params: Params;
71
- };
72
- 'journey:end': BaseContext & JourneyResult & PluginOutput & {
73
- journey: Journey;
74
- ssblocks?: boolean;
75
- };
76
- 'journey:end:reported': unknown;
77
- 'step:start': {
78
- journey: Journey;
79
- step: Step;
80
- };
81
- 'step:end': StepResult & {
82
- start: number;
83
- end: number;
84
- journey: Journey;
85
- step: Step;
86
- };
87
- end: unknown;
88
- }
89
- export default interface Runner {
90
- on<K extends keyof Events>(name: K, listener: (v: Events[K]) => void): this;
91
- emit<K extends keyof Events>(event: K, args: Events[K]): boolean;
92
- }
93
- export default class Runner extends EventEmitter {
94
- active: boolean;
95
- currentJourney?: Journey;
39
+ export default class Runner {
40
+ #private;
96
41
  journeys: Journey[];
97
42
  hooks: SuiteHooks;
98
- screenshotPath: string;
43
+ hookError: Error | undefined;
44
+ monitor?: Monitor;
45
+ static screenshotPath: string;
99
46
  static createContext(options: RunOptions): Promise<JourneyContext>;
47
+ captureScreenshot(page: Driver['page'], step: Step): Promise<void>;
48
+ get currentJourney(): Journey;
100
49
  addHook(type: HookType, callback: HooksCallback): void;
50
+ updateMonitor(config: MonitorConfig): void;
101
51
  addJourney(journey: Journey): void;
52
+ setReporter(options: RunOptions): void;
102
53
  runBeforeAllHook(args: HooksArgs): Promise<void>;
103
54
  runAfterAllHook(args: HooksArgs): Promise<void>;
104
55
  runBeforeHook(journey: Journey, args: HooksArgs): Promise<void>;
@@ -107,10 +58,15 @@ export default class Runner extends EventEmitter {
107
58
  runSteps(journey: Journey, context: JourneyContext, options: RunOptions): Promise<StepResult[]>;
108
59
  registerJourney(journey: Journey, context: JourneyContext): void;
109
60
  endJourney(journey: any, result: JourneyContext & JourneyResult, options: RunOptions): Promise<void>;
61
+ /**
62
+ * Simulate a journey run to capture errors in the beforeAll hook
63
+ */
64
+ runFakeJourney(journey: Journey, options: RunOptions): Promise<JourneyResult>;
110
65
  runJourney(journey: Journey, options: RunOptions): Promise<JourneyResult>;
111
- init(options: RunOptions): void;
66
+ init(options: RunOptions): Promise<void>;
67
+ buildMonitors(options: RunOptions): Monitor[];
112
68
  run(options: RunOptions): Promise<RunResult>;
113
- reset(): void;
69
+ reset(): Promise<void>;
114
70
  }
115
71
  export {};
116
72
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/core/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAEH,OAAO,EAAQ,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQnD,OAAO,EACL,WAAW,EACX,aAAa,EACb,MAAM,EACN,YAAY,EACZ,OAAO,EACP,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAsB,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,MAAM,EAAY,MAAM,YAAY,CAAC;AAG9C,oBAAY,UAAU,GAAG,IAAI,CAC3B,OAAO,EACL,OAAO,GACP,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,aAAa,GACb,UAAU,GACV,YAAY,GACZ,YAAY,CACf,GAAG;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC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