@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.17

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 (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
@@ -3,18 +3,19 @@ import { Subscription } from '../pubsub/subscription.js';
3
3
  import { fromMessageAttributes } from '../internal/reqfields.js';
4
4
  import { begin, hookScope, isContext, requireScope, requireScopes, runIn, Scope, setupHooks, systemTest, testMode, testName, } from '../internal/testing/scope.js';
5
5
  export * as system from './system.js';
6
- /** The hooks {@link setup} was given, for {@link useFixture}. */
6
+ /** Runner hooks registered via {@link setup}, used by {@link useFixture}. */
7
7
  let registered;
8
8
  /**
9
- * Registers per-test infrastructure with a runner's hooks: each test begins
10
- * with resources of its own, released after it. The per-runner entry points
11
- * (`@encore.dev/sdk/testing/vitest` and the others) call this for you.
9
+ * Registers per-test infrastructure lifecycle hooks with a test runner so each
10
+ * test starts with isolated resources that are released when it finishes. The
11
+ * runner adapters (`@encore.dev/sdk/testing/vitest`, etc.) call this
12
+ * automatically.
12
13
  *
13
- * Once it has, a resource used outside any test — in a `beforeAll`, or at
14
- * module level — throws: no test would see what it does. Set up what each
15
- * test needs in `beforeEach`, or in a {@link fixture}.
14
+ * Once registered, accessing infrastructure outside a test (for example in
15
+ * `beforeAll` or at module top level) throws because no test would see those
16
+ * writes. Seed shared test data in `beforeEach` or with a {@link fixture}.
16
17
  *
17
- * Outside test mode it registers nothing, so a test file still runs.
18
+ * Outside test mode, this is a no-op so test files can still be imported.
18
19
  */
19
20
  export function setup(hooks, options) {
20
21
  registered = hooks;
@@ -22,19 +23,20 @@ export function setup(hooks, options) {
22
23
  setupHooks(hooks, fixture === undefined ? undefined : scope => choose(scope, fixture));
23
24
  }
24
25
  /**
25
- * Wraps a test body to run in a scope of its own: for concurrent tests,
26
- * which the runner's hooks cannot tell apart, or a runner without hooks.
26
+ * Wraps a test function in its own isolated resource scope. Use this for
27
+ * concurrent tests (which runner lifecycle hooks cannot distinguish) or runners
28
+ * without hooks.
27
29
  *
28
30
  * ```ts
29
31
  * test.concurrent("x", scoped(async () => { ... }));
30
32
  * ```
31
33
  *
32
- * The test starts from `options.fixture` if given, else from the fixture
33
- * {@link useFixture} chose for it, where the runner hands the test its
34
- * context (vitest, node:test). Outside test mode it runs `fn` as it is.
34
+ * Starts from `options.fixture` if specified, otherwise from any fixture
35
+ * configured via {@link useFixture} (when the runner supplies a test context,
36
+ * as in Vitest and `node:test`). Outside test mode, runs `fn` directly.
35
37
  *
36
- * A system test wrapped in it says how it ended in any runner, and prints
37
- * what it caused in the app when it fails: see {@link system}.
38
+ * Wrapping a system test in `scoped` also reports its pass/fail outcome in any
39
+ * runner and prints app telemetry when it fails (see {@link system}).
38
40
  */
39
41
  export function scoped(fn, options) {
40
42
  // No parameters by name: jest and bun pass a test with parameters a
@@ -65,19 +67,20 @@ export function scoped(fn, options) {
65
67
  };
66
68
  }
67
69
  /**
68
- * What the current test has published to `topic`, in the order it was
69
- * published: by the test itself, and by the code it called. Nothing handles
70
- * it otherwise: hand it to a subscription with {@link deliver}.
70
+ * Returns all messages published to `topic` during the current test (whether
71
+ * published directly by the test or by code it called), in publish order.
72
+ * Messages are not delivered automatically in unit tests; pass the subscription
73
+ * to {@link deliver} to invoke its handler.
71
74
  *
72
- * Each message's `data` is what was published: decoded from JSON, or the
73
- * bytes published as bytes.
75
+ * Each message's `data` is JSON-decoded unless it was published as raw bytes.
74
76
  *
75
- * Not in a system test, where what a test publishes is sent.
77
+ * Not available in system tests, where published messages are delivered to
78
+ * running services automatically.
76
79
  */
77
80
  export function published(topic) {
78
81
  if (systemTest !== null) {
79
- throw new Error('what a system test published is sent, and is not kept by the test: read what ' +
80
- 'the app did with it instead, once it has `settled`');
82
+ throw new Error('published() is not available in system tests because messages are delivered ' +
83
+ 'to running services: await system.settled() and assert on the resulting state instead');
81
84
  }
82
85
  const scope = requireScope();
83
86
  return scope.native.published(topic.name).map(msg => ({
@@ -93,67 +96,64 @@ export function published(topic) {
93
96
  }));
94
97
  }
95
98
  /**
96
- * Runs `subscription`'s handler on each message the current test — or the
97
- * code it called — published to its topic that the subscription has not
98
- * handled yet, one at a time, in the order they were published, as part of
99
- * the test. Resolves to how many it handled.
99
+ * Invokes `subscription`'s handler sequentially for every matching undelivered
100
+ * message published to its topic during the current test, returning the number
101
+ * of messages handled.
100
102
  *
101
- * As in a real delivery, the handler gets a message only if the
102
- * subscription's filter matches it, decoded as the subscription says, with
103
- * the Request Context fields it was published with, and `deliveryAttempt` 1
104
- * the first time. What the handler publishes to the topic in turn is handed
105
- * over in the same call.
103
+ * Just like in production, messages are filtered by the subscription's filter,
104
+ * decoded using its encoding settings, and delivered with their propagated
105
+ * Request Context fields (starting at `deliveryAttempt: 1`). Messages published
106
+ * back to the same topic by the handler are also delivered during the same call.
106
107
  *
107
- * It stops at the first message the handler fails, and rejects with its
108
- * error. That message stays unhandled: the next call hands it over again,
109
- * its `deliveryAttempt` one more. Retry policies, ack deadlines and dead
110
- * letters play no part.
108
+ * Stops on the first handler error and rejects with it. The failed message
109
+ * remains pending and will be retried on the next `deliver()` call with an
110
+ * incremented `deliveryAttempt`. Retry policies, ack deadlines, and dead-letter
111
+ * queues do not apply.
111
112
  *
112
- * Not in a system test, where the subscriptions run on their own: wait for
113
- * them with `system.settled()`.
113
+ * Not available in system tests, where subscriptions run automatically — use
114
+ * `system.settled()` instead.
114
115
  */
115
116
  export async function deliver(subscription) {
116
117
  if (systemTest !== null) {
117
- throw new Error('subscriptions run on their own in a system test, in the services that declare ' +
118
- 'them: wait for them to have handled what was published with `system.settled()`');
118
+ throw new Error('deliver() is not available in system tests because subscriptions run automatically ' +
119
+ 'in their declaring services: await system.settled() instead');
119
120
  }
120
121
  const scope = requireScope();
121
122
  return Subscription.deliverIn(subscription, scope, requireScopes().maxDeliveries);
122
123
  }
123
124
  /**
124
- * Gives `secret` a value for the current test, in place of the app's. No
125
- * other test sees it, and it is gone when the test ends.
125
+ * Overrides `secret` with `value` for the current test only. Other tests do
126
+ * not see the override, and it is cleared when the test ends.
126
127
  *
127
- * Not in a system test, whose services read their own values: give the
128
- * secret its value for tests in `secrets.test.toml` instead.
128
+ * Not available in system tests, where services read their own secrets — set
129
+ * test secret values in `secrets.test.toml` instead.
129
130
  */
130
131
  export function setSecret(secret, value) {
131
132
  if (systemTest !== null) {
132
- throw new Error("a system test can't give a secret a value of its own: the services it calls read " +
133
- "theirs, not the test's. Give the secret its value for tests in secrets.test.toml");
133
+ throw new Error('setSecret() is not available in system tests because running services read their ' +
134
+ 'own secrets: configure test secret values in secrets.test.toml instead');
134
135
  }
135
136
  requireScope().native.setSecret(secret.name, Buffer.from(value));
136
137
  }
137
138
  /**
138
- * Gives `config` a value for the current test, in place of the app's: what
139
- * calling the config returns in the test from then on. No other test sees
140
- * it, and it is gone when the test ends. Throws if the value does not
141
- * satisfy the config's schema.
139
+ * Overrides `config` with `value` for the current test only. Other tests do
140
+ * not see the override, and it is cleared when the test ends. Throws if
141
+ * `value` fails schema validation.
142
142
  *
143
- * Not in a system test, whose services read their own values: give the
144
- * config its value for tests in its `test` config file instead.
143
+ * Not available in system tests, where services read their own config files —
144
+ * set test config values in `<name>.test.config.toml` instead.
145
145
  */
146
146
  export function setConfig(config, value) {
147
147
  if (systemTest !== null) {
148
- throw new Error("a system test can't give a config a value of its own: the services it calls read " +
149
- "theirs, not the test's. Give the config its value for tests in its `test` config " +
150
- 'file (<name>.test.config.toml)');
148
+ throw new Error('setConfig() is not available in system tests because running services read their ' +
149
+ 'own config files: configure test values in <name>.test.config.toml instead');
151
150
  }
152
151
  setTestValue(requireScope(), config, value);
153
152
  }
154
153
  /**
155
- * Declares a fixture: a state `setup` leaves the app's resources in,
156
- * built once per test run and copied for each test that starts from it.
154
+ * Declares a reusable {@link Fixture}: runs `setup` once per test run, saves
155
+ * the resulting state of all touched databases, buckets, and Redis databases,
156
+ * and gives each test that loads it an isolated copy.
157
157
  *
158
158
  * ```ts
159
159
  * const seeded = fixture("users.seeded", async () => {
@@ -162,15 +162,9 @@ export function setConfig(config, value) {
162
162
  * useFixture(seeded);
163
163
  * ```
164
164
  *
165
- * The setup is ordinary app code: its resources are the fixture's while it
166
- * runs. It runs the first time a test loads the fixture, however many test
167
- * files and workers load it. What it leaves in each database, bucket and
168
- * Redis database it touched is saved; each test that loads the fixture gets
169
- * a copy of its own. Other kinds of resource start each test from their
170
- * initial state.
171
- *
172
- * The name identifies the fixture across the app's test files: two fixtures
173
- * of one name are one fixture, built by whichever is loaded first.
165
+ * `setup` runs normal application code on the first load across all test files
166
+ * and workers. Other resource types start from their initial empty state.
167
+ * Fixtures with the same `name` refer to the same snapshot across files.
174
168
  */
175
169
  export function fixture(name, setup, options) {
176
170
  const f = {
@@ -182,18 +176,18 @@ export function fixture(name, setup, options) {
182
176
  return f;
183
177
  }
184
178
  /**
185
- * Makes `f` what every test after this call in the file — or, called in a
186
- * `describe` block, in the block — starts from; `null` for the resources'
187
- * initial state. A {@link scoped} test starts from it too, unless told
188
- * otherwise. Needs the runner adapter (or {@link setup}), whose hooks it
189
- * adds to. Outside test mode it does nothing.
179
+ * Sets `f` as the default starting fixture for subsequent tests in the current
180
+ * file or `describe` block (pass `null` to reset to freshly provisioned empty
181
+ * resources). Also applies to {@link scoped} tests unless overridden.
182
+ *
183
+ * Requires a test runner adapter (or {@link setup}). No-op outside test mode.
190
184
  */
191
185
  export function useFixture(f) {
192
186
  if (!testMode)
193
187
  return;
194
188
  if (registered === undefined) {
195
- throw new Error('useFixture needs the runner adapter for your test runner, such as ' +
196
- "@encore.dev/sdk/testing/vitest in vitest's setupFiles");
189
+ throw new Error('useFixture() requires a test runner adapter (e.g. add ' +
190
+ '"@encore.dev/sdk/testing/vitest" to Vitest setupFiles)');
197
191
  }
198
192
  registered.beforeEach((...args) => {
199
193
  const ctx = args[0];
@@ -203,26 +197,26 @@ export function useFixture(f) {
203
197
  return scope === null ? undefined : choose(scope, f);
204
198
  });
205
199
  }
206
- /** Each fixture's setup. */
200
+ /** Maps each fixture handle to its setup function. */
207
201
  const setups = new WeakMap();
208
- /** The fixture `useFixture` chose for the test of a runner's context. */
202
+ /** Maps runner test contexts to the fixture selected via `useFixture`. */
209
203
  const chosenFor = new WeakMap();
210
204
  function chosen(ctx) {
211
205
  return isContext(ctx) ? chosenFor.get(ctx) : undefined;
212
206
  }
213
- /** Makes `scope`'s test start from `f`, or from nothing for `null`. */
207
+ /** Applies fixture `f` (or clears the fixture when `null`) on `scope`. */
214
208
  async function choose(scope, f) {
215
209
  if (f === null)
216
210
  scope.native.useFixture(null);
217
211
  else
218
212
  await load(f, scope);
219
213
  }
220
- /** Loads the fixture `f` into `scope`, building it first if need be. */
214
+ /** Ensures fixture `f` is built and applies it to `scope`. */
221
215
  async function load(f, scope) {
222
216
  await ensureBuilt(f);
223
217
  scope.native.useFixture(f.name);
224
218
  }
225
- /** Each fixture's build, as far as this process has asked. */
219
+ /** Tracks in-flight or completed fixture builds in this process. */
226
220
  const builds = new WeakMap();
227
221
  function ensureBuilt(f) {
228
222
  let built = builds.get(f);
@@ -232,12 +226,12 @@ function ensureBuilt(f) {
232
226
  }
233
227
  return built;
234
228
  }
235
- /** Builds the fixture `f`, unless this process or another has already. */
229
+ /** Builds fixture `f` if no process has built it yet in this test run. */
236
230
  async function build(f) {
237
231
  if (f.parent !== undefined)
238
232
  await ensureBuilt(f.parent);
239
233
  const scopes = requireScopes();
240
- const failed = (reason, cause) => new Error(`cannot load the fixture ${JSON.stringify(f.name)}: ${reason}`, {
234
+ const failed = (reason, cause) => new Error(`failed to load fixture ${JSON.stringify(f.name)}: ${reason}`, {
241
235
  cause,
242
236
  });
243
237
  let native;
@@ -255,7 +249,7 @@ async function build(f) {
255
249
  await runIn(scope, async () => setups.get(f)());
256
250
  }
257
251
  catch (err) {
258
- const error = failed(`its setup failed: ${err instanceof Error ? err.message : String(err)}`, err);
252
+ const error = failed(`setup failed: ${err instanceof Error ? err.message : String(err)}`, err);
259
253
  scopes.failFixture(f.name, error.message);
260
254
  scope.end();
261
255
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../testing/mod.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAC,YAAY,EAAc,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,YAAY,EACZ,aAAa,EACb,KAAK,EACL,KAAK,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,GAET,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAWnC,iEAAiE;AACjE,IAAI,UAA6B,CAAC;AAElC;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AAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,MAAM,CAClB,iBAAiB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACnE,GAAG,CACJ,CAAC;QACF,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,CAAC,GAAG,EAAE,CAAC;QACZ,MAAM,KAAK,CAAC;IACd,CAAC;IACD,2DAA2D;IAC3D,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,CAAE,GAAa,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
@@ -1,18 +1,15 @@
1
1
  /**
2
- * A system test's browser, driven with Playwright.
2
+ * Playwright adapter for driving Encore's managed system-test browser.
3
3
  *
4
- * {@link connect} connects Playwright to the browser Encore runs for the
5
- * current test (see `system.browser` in `@encore.dev/sdk/testing`): a page
6
- * reaches the app where `encore run` has it, in the test session; its
7
- * requests are the test's; and what it shows is recorded. Each call the
8
- * test makes on a page or a locator is reported as it is written, with
9
- * where it is, so that the recording and the test's telemetry say which
10
- * statement had the browser do what.
4
+ * {@link connect} attaches Playwright to the Chromium instance Encore starts
5
+ * for the current test (see `system.browser` in `@encore.dev/sdk/testing`).
6
+ * Requests from pages route to the test session under your test's isolated
7
+ * data, pages are recorded, and every page or locator call is automatically
8
+ * tracked with its call site in test telemetry and recordings.
11
9
  *
12
- * Playwright is the test's own, passed in: `playwright` or
13
- * `playwright-core`. It drives Encore's browser over the DevTools Protocol
14
- * (`connectOverCDP`), so it needs no browser of its own installed, and it
15
- * is Chromium that is driven.
10
+ * Pass your own `playwright` or `playwright-core` `chromium` module; because
11
+ * Playwright connects over CDP (`connectOverCDP`), no separate Playwright
12
+ * browser download is required.
16
13
  *
17
14
  * @example
18
15
  * // With any test runner:
@@ -28,7 +25,7 @@
28
25
  * });
29
26
  *
30
27
  * @example
31
- * // With Playwright Test, which is its own runner:
28
+ * // With Playwright Test:
32
29
  * import {test as base, expect} from "@playwright/test";
33
30
  * import {extend} from "@encore.dev/sdk/testing/playwright";
34
31
  *
@@ -45,45 +42,44 @@
45
42
  */
46
43
  import '../internal/testing/runner.js';
47
44
  import { type BrowserOptions } from './system.js';
48
- /** Playwright's `chromium`, as much of it as {@link connect} uses. */
45
+ /** Minimal subset of Playwright's `chromium` required by {@link connect}. */
49
46
  export interface Chromium<B> {
50
47
  connectOverCDP(endpointURL: string, options?: Record<string, unknown>): Promise<B>;
51
48
  }
52
- /** The options of {@link connect}. */
49
+ /** Options for {@link connect}. */
53
50
  export interface ConnectOptions extends BrowserOptions {
54
- /** More of Playwright's own options for `connectOverCDP`, such as `slowMo`. */
51
+ /** Additional Playwright options passed to `connectOverCDP` (e.g. `slowMo`). */
55
52
  connect?: Record<string, unknown>;
56
53
  }
57
54
  /**
58
- * Connects `chromium` to the current test's browser, starting it if the
59
- * test has none yet, and returns Playwright's `Browser`. The browser ends
60
- * with the test: there is nothing to close.
55
+ * Connects Playwright's `chromium` to the current test's Encore browser
56
+ * (starting it if needed) and returns the Playwright `Browser`. The browser is
57
+ * automatically closed when the test ends.
61
58
  */
62
59
  export declare function connect<B>(chromium: Chromium<B>, options?: ConnectOptions): Promise<B>;
63
60
  /**
64
- * The URL a page of the current test's browser reaches the gateway or
65
- * frontend `name` at: the one `encore run` has it at, which the frontend is
66
- * written against.
61
+ * Returns the URL a page in the current test's browser uses to reach gateway
62
+ * or frontend `name` (matching the local `encore run` origin).
67
63
  */
68
64
  export declare function url(name: string): Promise<string>;
69
- /** What {@link extend} adds to Playwright Test's options. */
65
+ /** Extra Playwright Test options added by {@link extend}. */
70
66
  export interface Options {
71
67
  /**
72
- * The frontend whose address is the tests' `baseURL`, by name: `goto("/")`
73
- * then opens it. Without it the `baseURL` is the config's.
68
+ * Name of the frontend to use as `baseURL` so `page.goto("/")` opens it.
69
+ * Falls back to Playwright's configured `baseURL` when unset.
74
70
  */
75
71
  frontend: string | undefined;
76
- /** How each test wants its browser: see `system.browser`. */
72
+ /** Encore browser options for each test (see `system.browser`). */
77
73
  encoreBrowser: BrowserOptions;
78
74
  }
79
75
  /**
80
- * Playwright Test's `test`, made a system test's: each test runs as a test
81
- * of the suite, as under any runner's adapter, and its `context` and `page`
82
- * are of the browser Encore runs for it. Playwright launches no browser.
76
+ * Extends Playwright Test's `test` so each test runs in an Encore system test
77
+ * scope with `context` and `page` connected to Encore's managed browser
78
+ * (Playwright does not launch its own browser).
83
79
  *
84
- * It adds two options, set with `test.use`: {@link Options.frontend} and
85
- * {@link Options.encoreBrowser}. A test that failed has its recording
86
- * attached to its report.
80
+ * Adds {@link Options.frontend} and {@link Options.encoreBrowser} for use with
81
+ * `test.use(...)`, and attaches the HTML recording to Playwright's report when
82
+ * a test fails.
87
83
  *
88
84
  * ```ts
89
85
  * const test = extend(base);
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.d.ts","sourceRoot":"","sources":["../../testing/playwright.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,4BAA4B,CAAC;AAGpC,OAAO,EAAyB,KAAK,cAAc,EAAC,MAAM,UAAU,CAAC;AAErE,sEAAsE;AACtE,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,cAAc,CACZ,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC,CAAC;CACf;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EA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WZ;AAED;;;GAGG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEvD;AAED,6DAA6D;AAC7D,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,mEAAmE;IACnE,aAAa,EAAE,cAAc,CAAC;CAC/B;AAwCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAkFpC"}
@@ -1,18 +1,15 @@
1
1
  /**
2
- * A system test's browser, driven with Playwright.
2
+ * Playwright adapter for driving Encore's managed system-test browser.
3
3
  *
4
- * {@link connect} connects Playwright to the browser Encore runs for the
5
- * current test (see `system.browser` in `@encore.dev/sdk/testing`): a page
6
- * reaches the app where `encore run` has it, in the test session; its
7
- * requests are the test's; and what it shows is recorded. Each call the
8
- * test makes on a page or a locator is reported as it is written, with
9
- * where it is, so that the recording and the test's telemetry say which
10
- * statement had the browser do what.
4
+ * {@link connect} attaches Playwright to the Chromium instance Encore starts
5
+ * for the current test (see `system.browser` in `@encore.dev/sdk/testing`).
6
+ * Requests from pages route to the test session under your test's isolated
7
+ * data, pages are recorded, and every page or locator call is automatically
8
+ * tracked with its call site in test telemetry and recordings.
11
9
  *
12
- * Playwright is the test's own, passed in: `playwright` or
13
- * `playwright-core`. It drives Encore's browser over the DevTools Protocol
14
- * (`connectOverCDP`), so it needs no browser of its own installed, and it
15
- * is Chromium that is driven.
10
+ * Pass your own `playwright` or `playwright-core` `chromium` module; because
11
+ * Playwright connects over CDP (`connectOverCDP`), no separate Playwright
12
+ * browser download is required.
16
13
  *
17
14
  * @example
18
15
  * // With any test runner:
@@ -28,7 +25,7 @@
28
25
  * });
29
26
  *
30
27
  * @example
31
- * // With Playwright Test, which is its own runner:
28
+ * // With Playwright Test:
32
29
  * import {test as base, expect} from "@playwright/test";
33
30
  * import {extend} from "@encore.dev/sdk/testing/playwright";
34
31
  *
@@ -48,9 +45,9 @@ import { Steps, wrap } from '../internal/testing/steps.js';
48
45
  import { setup } from './mod.js';
49
46
  import { browser as testBrowser } from './system.js';
50
47
  /**
51
- * Connects `chromium` to the current test's browser, starting it if the
52
- * test has none yet, and returns Playwright's `Browser`. The browser ends
53
- * with the test: there is nothing to close.
48
+ * Connects Playwright's `chromium` to the current test's Encore browser
49
+ * (starting it if needed) and returns the Playwright `Browser`. The browser is
50
+ * automatically closed when the test ends.
54
51
  */
55
52
  export async function connect(chromium, options) {
56
53
  const info = await testBrowser(options);
@@ -60,15 +57,13 @@ export async function connect(chromium, options) {
60
57
  return wrap(browser, 'browser', steps);
61
58
  }
62
59
  /**
63
- * The URL a page of the current test's browser reaches the gateway or
64
- * frontend `name` at: the one `encore run` has it at, which the frontend is
65
- * written against.
60
+ * Returns the URL a page in the current test's browser uses to reach gateway
61
+ * or frontend `name` (matching the local `encore run` origin).
66
62
  */
67
63
  export async function url(name) {
68
64
  return (await testBrowser()).url(name);
69
65
  }
70
- /** The hooks that begin and end a test's scope, kept for the fixture to
71
- * call: Playwright Test has no hooks of its own outside a test file. */
66
+ /** Captures Encore's per-test scope hooks for Playwright Test fixtures. */
72
67
  let hooks;
73
68
  function scopeHooks() {
74
69
  if (hooks !== undefined)
@@ -89,13 +84,13 @@ function scopeHooks() {
89
84
  return hooks;
90
85
  }
91
86
  /**
92
- * Playwright Test's `test`, made a system test's: each test runs as a test
93
- * of the suite, as under any runner's adapter, and its `context` and `page`
94
- * are of the browser Encore runs for it. Playwright launches no browser.
87
+ * Extends Playwright Test's `test` so each test runs in an Encore system test
88
+ * scope with `context` and `page` connected to Encore's managed browser
89
+ * (Playwright does not launch its own browser).
95
90
  *
96
- * It adds two options, set with `test.use`: {@link Options.frontend} and
97
- * {@link Options.encoreBrowser}. A test that failed has its recording
98
- * attached to its report.
91
+ * Adds {@link Options.frontend} and {@link Options.encoreBrowser} for use with
92
+ * `test.use(...)`, and attaches the HTML recording to Playwright's report when
93
+ * a test fails.
99
94
  *
100
95
  * ```ts
101
96
  * const test = extend(base);
@@ -1 +1 @@
1
- {"version":3,"file":"playwright.js","sourceRoot":"","sources":["../../testing/playwright.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAC,OAAO,IAAI,WAAW,EAAsB,MAAM,UAAU,CAAC;AAuBrE;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAAqB,EACrB,OAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,cAAc,CAC3C,IAAI,CAAC,UAAU,EACf,OAAO,EAAE,OAAO,CACjB,CAAC;IACF,MAAM,OAAO,GAAG,MACd,OACD,CAAC,oBAAoB,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,OAAiB,EAAE,SAAS,EAAE,KAAK,CAAM,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAY;IACpC,OAAO,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AA+BD;wEACwE;AACxE,IAAI,KAA8C,CAAC;AAEnD,SAAS,UAAU;IACjB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,MAAwB,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AAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBAC7C,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;KACF,CAAC;IACF,wEAAwE;IACxE,OAAQ,IAA8B,CAAC,MAAM,CAAC,QAAQ,CAAM,CAAC;AAC/D,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type BrowserOptions } from './system.js';
2
- /** Puppeteer, as much of it as {@link connect} uses. */
2
+ /** Minimal subset of Puppeteer required by {@link connect}. */
3
3
  export interface Puppeteer<B> {
4
4
  connect(options: {
5
5
  browserWSEndpoint: string;
@@ -10,27 +10,26 @@ export interface Puppeteer<B> {
10
10
  [option: string]: unknown;
11
11
  }): Promise<B>;
12
12
  }
13
- /** The options of {@link connect}. */
13
+ /** Options for {@link connect}. */
14
14
  export interface ConnectOptions extends BrowserOptions {
15
15
  /**
16
- * More of Puppeteer's own options for `connect`, such as `slowMo` and
17
- * `protocolTimeout`.
16
+ * Additional Puppeteer options passed to `puppeteer.connect` (such as
17
+ * `slowMo` or `protocolTimeout`).
18
18
  */
19
19
  connect?: Record<string, unknown>;
20
20
  }
21
21
  /**
22
- * Connects `puppeteer` to the current test's browser, starting it if the
23
- * test has none yet, and returns Puppeteer's `Browser`. The browser ends
24
- * with the test: there is nothing to close.
22
+ * Connects `puppeteer` to the current test's Encore browser (starting it if
23
+ * needed) and returns the Puppeteer `Browser`. The browser is automatically
24
+ * closed when the test ends.
25
25
  *
26
- * Its pages' viewport is the browser's window (`options.window`), unless
27
- * `options.connect.defaultViewport` says otherwise.
26
+ * Page viewports match `options.window` (defaulting to 1280×800) unless
27
+ * overridden via `options.connect.defaultViewport`.
28
28
  */
29
29
  export declare function connect<B>(puppeteer: Puppeteer<B>, options?: ConnectOptions): Promise<B>;
30
30
  /**
31
- * The URL a page of the current test's browser reaches the gateway or
32
- * frontend `name` at: the one `encore run` has it at, which the frontend is
33
- * written against.
31
+ * Returns the URL a page in the current test's browser uses to reach gateway
32
+ * or frontend `name` (matching the local `encore run` origin).
34
33
  */
35
34
  export declare function url(name: string): Promise<string>;
36
35
  //# sourceMappingURL=puppeteer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"puppeteer.d.ts","sourceRoot":"","sources":["../../testing/puppeteer.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAyB,KAAK,cAAc,EAAC,MAAM,UAAU,CAAC;AAErE,wDAAwD;AACxD,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,OAAO,CAAC,OAAO,EAAE;QACf,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,CAAC,EAAE;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAC,GAAG,IAAI,CAAC;QACzD,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;KAC3B,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChB;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAWD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC,CAcZ;AAED;;;;GAIG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEvD"}
1
+ {"version":3,"file":"puppeteer.d.ts","sourceRoot":"","sources":["../../testing/puppeteer.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAyB,KAAK,cAAc,EAAC,MAAM,UAAU,CAAC;AAErE,+DAA+D;AAC/D,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,OAAO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