@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.
- package/README.md +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.ts +209 -239
- package/storage/objects/error.ts +4 -4
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Puppeteer adapter for driving Encore's managed system-test browser.
|
|
3
3
|
*
|
|
4
|
-
* {@link connect}
|
|
5
|
-
* current test (see `system.browser` in `@encore.dev/sdk/testing`)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* {@link connect} attaches Puppeteer 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, and page sessions are recorded.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Every page call is automatically tracked with its call site so test
|
|
10
|
+
* telemetry and recordings link each test statement to the browser actions and
|
|
11
|
+
* backend requests it triggered:
|
|
12
12
|
*
|
|
13
13
|
* page.locator("#pay").click() checkout.test.ts:14
|
|
14
14
|
* click button "Pay"
|
|
15
15
|
* POST http://localhost:4000/orders 500
|
|
16
16
|
* POST orders /orders 500
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Pass your own `puppeteer` or `puppeteer-core` module; no separate browser
|
|
19
|
+
* download is needed because Encore manages Chromium.
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* import puppeteer from "puppeteer-core";
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
import { Steps, wrap } from '../internal/testing/steps.js';
|
|
38
38
|
import { browser as testBrowser } from './system.js';
|
|
39
39
|
/**
|
|
40
|
-
* Connects `puppeteer` to the current test's browser
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* Connects `puppeteer` to the current test's Encore browser (starting it if
|
|
41
|
+
* needed) and returns the Puppeteer `Browser`. The browser is automatically
|
|
42
|
+
* closed when the test ends.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
* `options.connect.defaultViewport
|
|
44
|
+
* Page viewports match `options.window` (defaulting to 1280×800) unless
|
|
45
|
+
* overridden via `options.connect.defaultViewport`.
|
|
46
46
|
*/
|
|
47
47
|
export async function connect(puppeteer, options) {
|
|
48
48
|
const info = await testBrowser(options);
|
|
@@ -60,9 +60,8 @@ export async function connect(puppeteer, options) {
|
|
|
60
60
|
return wrap(browser, 'browser', steps);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* frontend `name`
|
|
65
|
-
* written against.
|
|
63
|
+
* Returns the URL a page in the current test's browser uses to reach gateway
|
|
64
|
+
* or frontend `name` (matching the local `encore run` origin).
|
|
66
65
|
*/
|
|
67
66
|
export async function url(name) {
|
|
68
67
|
return (await testBrowser()).url(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer.js","sourceRoot":"","sources":["../../testing/puppeteer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAC,OAAO,IAAI,WAAW,EAAsB,MAAM,UAAU,CAAC;AA6BrE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,SAAuB,EACvB,OAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;QACtC,eAAe,EAAE,OAAO,EAAE,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AAE,CAAC;IACtB,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;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAY;IACpC,OAAO,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/testing/system.d.ts
CHANGED
|
@@ -2,31 +2,26 @@ import { Telemetry } from '../internal/testing/telemetry.js';
|
|
|
2
2
|
export { Telemetry } from '../internal/testing/telemetry.js';
|
|
3
3
|
export type { LostContext } from '../internal/testing/telemetry.js';
|
|
4
4
|
export type { DeliveryWhat, Filter, HopWhat, Log, OtherWhat, PublishWhat, QueryWhat, RequestWhat, Span, SpanEvent, SpanKind, SpanLink, SpanStatus, TestWhat, What, } from '../internal/testing/telemetry.js';
|
|
5
|
-
/**
|
|
5
|
+
/** Options for {@link settled}. */
|
|
6
6
|
export interface SettledOptions {
|
|
7
|
-
/**
|
|
7
|
+
/** Maximum wait time in milliseconds. Defaults to 30,000 ms (30 seconds). */
|
|
8
8
|
timeout?: number;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Waits until
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* then, with an error saying what was still under way.
|
|
11
|
+
* Waits until all asynchronous work triggered by the current test has finished
|
|
12
|
+
* — no requests are in flight to services or gateways, and no Pub/Sub messages
|
|
13
|
+
* are queued, in progress, or awaiting retry. Rejects after 30 seconds (or
|
|
14
|
+
* `options.timeout`) with details of what is still pending.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* for, and is done on data the test does not see. The test's telemetry says
|
|
23
|
-
* which call lost it.
|
|
16
|
+
* Only work tagged with the current test's propagated ID is tracked, so
|
|
17
|
+
* parallel tests do not block one another and unrelated background activity is
|
|
18
|
+
* ignored. If a service fails to propagate request context on an outgoing call,
|
|
19
|
+
* that work loses the test ID, runs outside the test's isolated data, and is
|
|
20
|
+
* flagged in {@link telemetry}.
|
|
24
21
|
*
|
|
25
|
-
* In
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* What a service does that is neither — work that goes on after its request
|
|
29
|
-
* was answered — is not waited for.
|
|
22
|
+
* In suites configured with `"data": "shared"`, `settled()` waits for all
|
|
23
|
+
* in-flight work across the app. Fire-and-forget work that continues after a
|
|
24
|
+
* handler has already responded is not tracked.
|
|
30
25
|
*
|
|
31
26
|
* @example
|
|
32
27
|
* await orders.fetch("/orders", {method: "POST", body}); // publishes `order-placed`
|
|
@@ -34,14 +29,13 @@ export interface SettledOptions {
|
|
|
34
29
|
*/
|
|
35
30
|
export declare function settled(options?: SettledOptions): Promise<void>;
|
|
36
31
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
32
|
+
* Returns the URL of gateway or frontend `name` in the current test session,
|
|
33
|
+
* for use with custom clients (such as WebSockets). Frontends start lazily on
|
|
34
|
+
* first connection.
|
|
40
35
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* another client carries the test with {@link headers}.
|
|
36
|
+
* Encore SDK clients and generated gateway clients automatically attach the
|
|
37
|
+
* current test context. For custom HTTP clients, pass {@link headers} on each
|
|
38
|
+
* request.
|
|
45
39
|
*
|
|
46
40
|
* @example
|
|
47
41
|
* import {Client} from "./encore_gen/gateway/api";
|
|
@@ -49,9 +43,9 @@ export declare function settled(options?: SettledOptions): Promise<void>;
|
|
|
49
43
|
*/
|
|
50
44
|
export declare function url(name: string): string;
|
|
51
45
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
46
|
+
* Returns lowercase HTTP headers that bind a custom client's request to the
|
|
47
|
+
* current test (carrying the test ID Request Context field and active trace
|
|
48
|
+
* span).
|
|
55
49
|
*
|
|
56
50
|
* @example
|
|
57
51
|
* const res = await fetch(`${system.url("api")}/health`, {
|
|
@@ -59,29 +53,26 @@ export declare function url(name: string): string;
|
|
|
59
53
|
* });
|
|
60
54
|
*/
|
|
61
55
|
export declare function headers(): Record<string, string>;
|
|
62
|
-
/**
|
|
56
|
+
/** Options for {@link telemetry}. */
|
|
63
57
|
export interface TelemetryOptions {
|
|
64
58
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
59
|
+
* Wait for the app to settle (as in {@link settled}) before reading recorded
|
|
60
|
+
* telemetry so all triggered work is captured. Set to `false` to read a
|
|
61
|
+
* snapshot immediately. Defaults to `true`.
|
|
68
62
|
*/
|
|
69
63
|
settle?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* seconds when not given. */
|
|
64
|
+
/** Maximum time to wait for settling, in milliseconds. Defaults to 30,000 ms. */
|
|
72
65
|
timeout?: number;
|
|
73
66
|
}
|
|
74
67
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* requests
|
|
78
|
-
* and the lines logged in them.
|
|
68
|
+
* Returns all telemetry recorded by the app for the current test (waiting for
|
|
69
|
+
* {@link settled} by default): every span triggered across services,
|
|
70
|
+
* inter-service requests, and Pub/Sub deliveries, along with their logs.
|
|
79
71
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* keep as a snapshot of which services a flow touches.
|
|
72
|
+
* Inspect typed span details via {@link Span.what} (requests, queries,
|
|
73
|
+
* publishes, deliveries). Converting the result to a string renders the same
|
|
74
|
+
* trace tree printed on test failure, and {@link Telemetry.shape} strips
|
|
75
|
+
* run-specific values for snapshot testing.
|
|
85
76
|
*
|
|
86
77
|
* @example
|
|
87
78
|
* const recorded = await system.telemetry();
|
|
@@ -90,50 +81,49 @@ export interface TelemetryOptions {
|
|
|
90
81
|
* expect(recorded.errors()).toEqual([]);
|
|
91
82
|
*/
|
|
92
83
|
export declare function telemetry(options?: TelemetryOptions): Promise<Telemetry>;
|
|
93
|
-
/**
|
|
84
|
+
/** Options for {@link browser}. */
|
|
94
85
|
export interface BrowserOptions {
|
|
95
86
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
87
|
+
* Controls when browser recordings are saved: `'failed'` (failed tests or
|
|
88
|
+
* runners that do not report outcomes), `'all'`, or `'off'`. Defaults to
|
|
89
|
+
* `ENCORE_TEST_RECORD` if set, otherwise `'failed'`.
|
|
99
90
|
*/
|
|
100
91
|
record?: 'failed' | 'all' | 'off';
|
|
101
|
-
/**
|
|
92
|
+
/** Additional command-line flags passed to Chromium. */
|
|
102
93
|
args?: string[];
|
|
103
|
-
/**
|
|
94
|
+
/** Browser viewport/window size in CSS pixels. Defaults to 1280×800. */
|
|
104
95
|
window?: {
|
|
105
96
|
width: number;
|
|
106
97
|
height: number;
|
|
107
98
|
};
|
|
108
99
|
}
|
|
109
|
-
/**
|
|
100
|
+
/** Handle to the current test's managed Chromium instance (see {@link browser}). */
|
|
110
101
|
export interface Browser {
|
|
111
102
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* `connectOverCDP`.
|
|
103
|
+
* Chrome DevTools Protocol WebSocket endpoint for connecting tools such as
|
|
104
|
+
* Puppeteer (`connect`) or Playwright (`connectOverCDP`).
|
|
115
105
|
*/
|
|
116
106
|
readonly wsEndpoint: string;
|
|
117
107
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
108
|
+
* Path to the self-contained HTML recording file written when the test ends,
|
|
109
|
+
* replaying page frames alongside test steps and backend telemetry, or `null`
|
|
110
|
+
* if recording is disabled.
|
|
121
111
|
*/
|
|
122
112
|
readonly recording: string | null;
|
|
123
113
|
/**
|
|
124
|
-
*
|
|
125
|
-
* `encore run`
|
|
126
|
-
*
|
|
114
|
+
* Returns the URL a browser page uses to reach gateway or frontend `name`
|
|
115
|
+
* (matching the local `encore run` origin, transparently routed to the test
|
|
116
|
+
* session).
|
|
127
117
|
*/
|
|
128
118
|
url(name: string): string;
|
|
129
119
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* the
|
|
133
|
-
* It resolves to what `fn` returns, and a `fn` that throws fails the step.
|
|
120
|
+
* Groups the actions and network requests inside `fn` under a named step in
|
|
121
|
+
* test telemetry and browser recordings (including the call site). Returns
|
|
122
|
+
* the result of `fn`, marking the step failed if `fn` throws.
|
|
134
123
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
124
|
+
* Browser adapters (`@encore.dev/sdk/testing/playwright` and `puppeteer`)
|
|
125
|
+
* record individual page calls automatically; use `step` for custom CDP tools
|
|
126
|
+
* or to group multiple calls under a higher-level label.
|
|
137
127
|
*
|
|
138
128
|
* @example
|
|
139
129
|
* await browser.step("pay with a saved card", async () => {
|
|
@@ -144,32 +134,24 @@ export interface Browser {
|
|
|
144
134
|
step<R>(name: string, fn: () => R | Promise<R>): Promise<R>;
|
|
145
135
|
}
|
|
146
136
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* test asks, and ends with the test.
|
|
150
|
-
*
|
|
151
|
-
* It is the test's in every way a call the test makes is:
|
|
152
|
-
*
|
|
153
|
-
* - It reaches the app where `encore run` has it. A frontend says itself
|
|
154
|
-
* where its API is, as `http://localhost:4000`: a page's requests there,
|
|
155
|
-
* and to the frontends' own addresses, go to the test session.
|
|
156
|
-
* - Each request a page makes to the app carries the test, so what the app
|
|
157
|
-
* does for a click is done on the test's data, and {@link settled} waits
|
|
158
|
-
* for it.
|
|
159
|
-
* - What the test has the browser do, and each request a page makes, is in
|
|
160
|
-
* the test's {@link telemetry}, with what the app did for a request
|
|
161
|
-
* under it. So is what a page says went wrong: an error on its console,
|
|
162
|
-
* an exception nothing caught, a request that failed.
|
|
163
|
-
* - Its pages are recorded. A test that fails is left a file that plays
|
|
164
|
-
* them back beside all of that ({@link Browser.recording}).
|
|
137
|
+
* Starts (or returns) a headless Chromium instance managed by Encore for the
|
|
138
|
+
* current system test, automatically closed when the test ends.
|
|
165
139
|
*
|
|
166
|
-
* The
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
140
|
+
* The managed browser integrates directly with the test session:
|
|
141
|
+
* - Pages reach frontends and APIs at their usual `encore run` URLs (such as
|
|
142
|
+
* `http://localhost:4000`), transparently routed to the test session.
|
|
143
|
+
* - Every app request from a page carries the test ID, so backend work uses the
|
|
144
|
+
* test's isolated data and is waited on by {@link settled}.
|
|
145
|
+
* - Browser actions, page requests, console errors, uncaught page exceptions,
|
|
146
|
+
* and failed requests are captured in {@link telemetry} alongside backend
|
|
147
|
+
* spans.
|
|
148
|
+
* - Page sessions are recorded to an HTML file on failure (see
|
|
149
|
+
* {@link Browser.recording}).
|
|
170
150
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
151
|
+
* Prefer the Playwright (`@encore.dev/sdk/testing/playwright`) or Puppeteer
|
|
152
|
+
* (`@encore.dev/sdk/testing/puppeteer`) adapters when using those libraries;
|
|
153
|
+
* use this function directly for other Chrome DevTools Protocol clients.
|
|
154
|
+
* Encore downloads the `browser/chromium` component automatically on first use.
|
|
173
155
|
*
|
|
174
156
|
* @example
|
|
175
157
|
* const {wsEndpoint, url} = await system.browser();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../testing/system.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../testing/system.ts"],"names":[],"mappings":"AAsEA,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAC,SAAS,EAAC,MAAM,+BAA+B,CAAC;AACxD,YAAY,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