@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.
Files changed (202) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +123 -161
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +159 -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/expect.d.ts +25 -25
  13. package/dist/core/expect.d.ts.map +1 -1
  14. package/dist/core/expect.js.map +1 -1
  15. package/dist/core/gatherer.d.ts +4 -8
  16. package/dist/core/gatherer.d.ts.map +1 -1
  17. package/dist/core/gatherer.js +49 -15
  18. package/dist/core/gatherer.js.map +1 -1
  19. package/dist/core/index.d.ts +5 -1
  20. package/dist/core/index.d.ts.map +1 -1
  21. package/dist/core/index.js +23 -11
  22. package/dist/core/index.js.map +1 -1
  23. package/dist/core/logger.d.ts +0 -1
  24. package/dist/core/logger.d.ts.map +1 -1
  25. package/dist/core/logger.js +3 -16
  26. package/dist/core/logger.js.map +1 -1
  27. package/dist/core/runner.d.ts +21 -65
  28. package/dist/core/runner.d.ts.map +1 -1
  29. package/dist/core/runner.js +212 -93
  30. package/dist/core/runner.js.map +1 -1
  31. package/dist/dsl/index.js +5 -1
  32. package/dist/dsl/index.js.map +1 -1
  33. package/dist/dsl/journey.d.ts +9 -4
  34. package/dist/dsl/journey.d.ts.map +1 -1
  35. package/dist/dsl/journey.js +27 -7
  36. package/dist/dsl/journey.js.map +1 -1
  37. package/dist/dsl/monitor.d.ts +66 -0
  38. package/dist/dsl/monitor.d.ts.map +1 -0
  39. package/dist/dsl/monitor.js +63 -0
  40. package/dist/dsl/monitor.js.map +1 -0
  41. package/dist/dsl/step.d.ts +3 -2
  42. package/dist/dsl/step.d.ts.map +1 -1
  43. package/dist/dsl/step.js +2 -1
  44. package/dist/dsl/step.js.map +1 -1
  45. package/dist/formatter/javascript.d.ts +98 -0
  46. package/dist/formatter/javascript.d.ts.map +1 -0
  47. package/dist/formatter/javascript.js +295 -0
  48. package/dist/formatter/javascript.js.map +1 -0
  49. package/dist/generator/index.d.ts +29 -0
  50. package/dist/generator/index.d.ts.map +1 -0
  51. package/dist/generator/index.js +240 -0
  52. package/dist/generator/index.js.map +1 -0
  53. package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
  54. package/dist/generator/utils.d.ts.map +1 -0
  55. package/dist/generator/utils.js +80 -0
  56. package/dist/generator/utils.js.map +1 -0
  57. package/dist/helpers.d.ts +24 -1
  58. package/dist/helpers.d.ts.map +1 -1
  59. package/dist/helpers.js +126 -19
  60. package/dist/helpers.js.map +1 -1
  61. package/dist/index.d.ts +6 -7
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +5 -26
  64. package/dist/index.js.map +1 -1
  65. package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
  66. package/dist/loader.d.ts.map +1 -0
  67. package/dist/loader.js +152 -0
  68. package/dist/loader.js.map +1 -0
  69. package/dist/locations/index.d.ts +45 -0
  70. package/dist/locations/index.d.ts.map +1 -0
  71. package/dist/locations/index.js +90 -0
  72. package/dist/locations/index.js.map +1 -0
  73. package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
  74. package/dist/locations/public-locations.d.ts.map +1 -0
  75. package/dist/locations/public-locations.js +41 -0
  76. package/dist/locations/public-locations.js.map +1 -0
  77. package/dist/options.d.ts +41 -0
  78. package/dist/options.d.ts.map +1 -0
  79. package/dist/options.js +182 -0
  80. package/dist/options.js.map +1 -0
  81. package/dist/plugins/browser-console.d.ts +5 -4
  82. package/dist/plugins/browser-console.d.ts.map +1 -1
  83. package/dist/plugins/browser-console.js +27 -8
  84. package/dist/plugins/browser-console.js.map +1 -1
  85. package/dist/plugins/index.js +5 -1
  86. package/dist/plugins/index.js.map +1 -1
  87. package/dist/plugins/network.d.ts +20 -33
  88. package/dist/plugins/network.d.ts.map +1 -1
  89. package/dist/plugins/network.js +173 -214
  90. package/dist/plugins/network.js.map +1 -1
  91. package/dist/plugins/performance.d.ts +4 -19
  92. package/dist/plugins/performance.d.ts.map +1 -1
  93. package/dist/plugins/performance.js +5 -5
  94. package/dist/plugins/performance.js.map +1 -1
  95. package/dist/plugins/plugin-manager.d.ts +9 -5
  96. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  97. package/dist/plugins/plugin-manager.js +44 -29
  98. package/dist/plugins/plugin-manager.js.map +1 -1
  99. package/dist/plugins/tracing.d.ts +6 -6
  100. package/dist/plugins/tracing.d.ts.map +1 -1
  101. package/dist/plugins/tracing.js +8 -7
  102. package/dist/plugins/tracing.js.map +1 -1
  103. package/dist/push/bundler.d.ts +34 -0
  104. package/dist/push/bundler.d.ts.map +1 -0
  105. package/dist/push/bundler.js +123 -0
  106. package/dist/push/bundler.js.map +1 -0
  107. package/dist/push/index.d.ts +33 -0
  108. package/dist/push/index.d.ts.map +1 -0
  109. package/dist/push/index.js +174 -0
  110. package/dist/push/index.js.map +1 -0
  111. package/dist/push/monitor.d.ts +34 -0
  112. package/dist/push/monitor.d.ts.map +1 -0
  113. package/dist/push/monitor.js +78 -0
  114. package/dist/push/monitor.js.map +1 -0
  115. package/{src/reporters/reporter.ts → dist/push/plugin.d.ts} +8 -10
  116. package/dist/push/plugin.d.ts.map +1 -0
  117. package/dist/push/plugin.js +133 -0
  118. package/dist/push/plugin.js.map +1 -0
  119. package/dist/push/request.d.ts +43 -0
  120. package/dist/push/request.d.ts.map +1 -0
  121. package/dist/push/request.js +83 -0
  122. package/dist/push/request.js.map +1 -0
  123. package/dist/reporters/base.d.ts +14 -6
  124. package/dist/reporters/base.d.ts.map +1 -1
  125. package/dist/reporters/base.js +54 -48
  126. package/dist/reporters/base.js.map +1 -1
  127. package/dist/reporters/index.d.ts +18 -8
  128. package/dist/reporters/index.d.ts.map +1 -1
  129. package/dist/reporters/index.js.map +1 -1
  130. package/dist/reporters/json.d.ts +18 -67
  131. package/dist/reporters/json.d.ts.map +1 -1
  132. package/dist/reporters/json.js +153 -175
  133. package/dist/reporters/json.js.map +1 -1
  134. package/dist/reporters/junit.d.ts +7 -1
  135. package/dist/reporters/junit.d.ts.map +1 -1
  136. package/dist/reporters/junit.js +94 -89
  137. package/dist/reporters/junit.js.map +1 -1
  138. package/dist/sdk/lh-trace-processor.d.ts +35 -9
  139. package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
  140. package/dist/sdk/lh-trace-processor.js +114 -53
  141. package/dist/sdk/lh-trace-processor.js.map +1 -1
  142. package/dist/sdk/trace-metrics.d.ts +4 -4
  143. package/dist/sdk/trace-metrics.d.ts.map +1 -1
  144. package/dist/sdk/trace-metrics.js +5 -6
  145. package/dist/sdk/trace-metrics.js.map +1 -1
  146. package/dist/sdk/trace-processor.d.ts +11 -3
  147. package/dist/sdk/trace-processor.d.ts.map +1 -1
  148. package/dist/sdk/trace-processor.js +17 -9
  149. package/dist/sdk/trace-processor.js.map +1 -1
  150. package/dist/tsconfig.tsbuildinfo +1 -1888
  151. package/package.json +32 -20
  152. package/src/cli.ts +205 -152
  153. package/src/common_types.ts +192 -34
  154. package/src/config.ts +2 -5
  155. package/src/core/expect.ts +58 -24
  156. package/src/core/gatherer.ts +59 -24
  157. package/src/core/index.ts +36 -15
  158. package/src/core/logger.ts +1 -12
  159. package/src/core/runner.ts +215 -152
  160. package/src/dsl/journey.ts +37 -6
  161. package/src/dsl/monitor.ts +88 -0
  162. package/src/dsl/step.ts +9 -2
  163. package/src/formatter/javascript.ts +367 -0
  164. package/src/generator/index.ts +316 -0
  165. package/src/generator/utils.ts +80 -0
  166. package/src/helpers.ts +132 -12
  167. package/src/index.ts +22 -22
  168. package/src/loader.ts +171 -0
  169. package/src/locations/index.ts +108 -0
  170. package/src/locations/public-locations.ts +38 -0
  171. package/src/options.ts +211 -0
  172. package/src/plugins/browser-console.ts +30 -8
  173. package/src/plugins/network.ts +208 -267
  174. package/src/plugins/performance.ts +6 -22
  175. package/src/plugins/plugin-manager.ts +49 -31
  176. package/src/plugins/tracing.ts +8 -9
  177. package/src/push/bundler.ts +100 -0
  178. package/src/push/index.ts +202 -0
  179. package/src/push/monitor.ts +96 -0
  180. package/src/push/plugin.ts +119 -0
  181. package/src/push/request.ts +103 -0
  182. package/src/reporters/base.ts +63 -52
  183. package/src/reporters/index.ts +26 -3
  184. package/src/reporters/json.ts +203 -206
  185. package/src/reporters/junit.ts +98 -93
  186. package/src/sdk/lh-trace-processor.ts +132 -68
  187. package/src/sdk/trace-metrics.ts +10 -6
  188. package/src/sdk/trace-processor.ts +28 -13
  189. package/templates/.github/workflows/run-synthetics.yml +26 -0
  190. package/templates/README.md +21 -0
  191. package/templates/journeys/advanced-example-helpers.ts +54 -0
  192. package/templates/journeys/advanced-example.journey.ts +43 -0
  193. package/templates/journeys/example.journey.ts +18 -0
  194. package/templates/synthetics.config.ts +27 -0
  195. package/CHANGELOG.md +0 -102
  196. package/NOTICE.txt +0 -221
  197. package/dist/parse_args.d.ts.map +0 -1
  198. package/dist/parse_args.js +0 -89
  199. package/dist/parse_args.js.map +0 -1
  200. package/dist/reporters/reporter.d.ts.map +0 -1
  201. package/dist/reporters/reporter.js.map +0 -1
  202. 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,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,GAAG,GAAG,KAAK,EAAE,GAAG,CAA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;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
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM1D,wBAAgB,IAAI,SAAK;AAEzB,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAQ,UAEhD;AAED,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAEF,wBAAgB,gBAAgB,WAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,WAGrC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,UAE5C;AAMD,wBAAgB,YAAY,WAE3B;AAED;;GAEG;AACH,wBAAgB,GAAG,WAElB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,EAC/B,IAAI,EAAE,SAAS,mBAIhB;AAED,wBAAgB,cAAc,CAAC,GAAG,KAAA,kBAMjC;AAED,wBAAgB,WAAW,CAAC,IAAI,KAAA,WAE/B;AAED,wBAAgB,MAAM,CAAC,QAAQ,KAAA,WAE9B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,KAAA,EAAE,GAAG,KAAA,OAiBvD;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,GAAG,EACnD,GAAG,SAAK,iBAeT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBtE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,E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,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 util_1 = require("util");
35
+ const promises_1 = require("fs/promises");
36
36
  const perf_hooks_1 = require("perf_hooks");
37
- const statAsync = util_1.promisify(fs_1.default.lstat);
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
- succeeded: colors_1.green('✓'),
50
- failed: colors_1.red('✖'),
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-${process.hrtime().toString()}`);
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 readAsync(dir).then(arr => {
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 statAsync(abs).then(stats => stats.isDirectory()
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(cwd, '.synthetics', process.pid.toString());
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
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,yCAAwD;AACxD,4CAAoB;AACpB,+BAA8C;AAC9C,4CAAoB;AACpB,+BAAiC;AACjC,2CAAyC;AAGzC,MAAM,SAAS,GAAG,gBAAS,CAAC,YAAE,CAAC,KAAK,CAAC,CAAC;AACtC,MAAM,SAAS,GAAG,gBAAS,CAAC,YAAE,CAAC,OAAO,CAAC,CAAC;AACxC,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,SAAgB,IA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AAO,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 './core/runner';
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 { beforeAll, afterAll, journey, step, before, after } from './core';
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU;;;;;GAmB5C;AAED;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC;;;GAGG;AACH,YAAY,EACV,IAAI,EACJ,eAAe,EACf,sBAAsB,EACtB,UAAU,GACX,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"}
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.step = exports.journey = exports.afterAll = exports.beforeAll = exports.run = void 0;
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;;;;;;;;;;;;;;;;;;;;;;;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
25
  import { CliArgs } from './common_types';
26
- declare const command: import("commander").Command;
27
- declare const options: CliArgs;
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