@encore.dev/sdk 2.0.0-beta.8 → 2.0.0-beta.9
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 +54 -0
- package/app_meta.test.ts +25 -5
- package/app_meta.ts +43 -12
- package/config/config.test.ts +8 -12
- package/config/config.ts +16 -12
- package/config/secrets.ts +19 -10
- package/config/value.ts +13 -17
- package/cron/mod.test.ts +52 -0
- package/cron/mod.ts +9 -2
- package/dist/app_meta.d.ts +37 -12
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +1 -0
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +16 -12
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +5 -2
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +19 -10
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +19 -10
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +7 -5
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +10 -7
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +5 -1
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +8 -1
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +39 -0
- package/dist/frontends/mod.d.ts.map +1 -0
- package/dist/frontends/mod.js +47 -0
- package/dist/frontends/mod.js.map +1 -0
- package/dist/gateway/mod.d.ts +3 -2
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +3 -2
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateways/mod.d.ts +42 -0
- package/dist/gateways/mod.d.ts.map +1 -0
- package/dist/gateways/mod.js +55 -0
- package/dist/gateways/mod.js.map +1 -0
- package/dist/internal/fetch.d.ts +4 -0
- package/dist/internal/fetch.d.ts.map +1 -1
- package/dist/internal/fetch.js +12 -1
- package/dist/internal/fetch.js.map +1 -1
- package/dist/internal/otel/http.d.ts +11 -0
- package/dist/internal/otel/http.d.ts.map +1 -0
- package/dist/internal/otel/http.js +64 -0
- package/dist/internal/otel/http.js.map +1 -0
- package/dist/internal/otel/index.d.ts +1 -1
- package/dist/internal/otel/index.d.ts.map +1 -1
- package/dist/internal/otel/index.js +1 -1
- package/dist/internal/otel/index.js.map +1 -1
- package/dist/internal/otel/provider.d.ts +3 -0
- package/dist/internal/otel/provider.d.ts.map +1 -1
- package/dist/internal/otel/provider.js +3 -0
- package/dist/internal/otel/provider.js.map +1 -1
- package/dist/internal/otel/span.d.ts +11 -1
- package/dist/internal/otel/span.d.ts.map +1 -1
- package/dist/internal/otel/span.js +25 -2
- package/dist/internal/otel/span.js.map +1 -1
- package/dist/internal/reqfields.d.ts +26 -6
- package/dist/internal/reqfields.d.ts.map +1 -1
- package/dist/internal/reqfields.js +44 -7
- package/dist/internal/reqfields.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +36 -4
- package/dist/internal/runtime/napi/napi.d.cts +99 -4
- package/dist/internal/testing/carry.d.ts +49 -0
- package/dist/internal/testing/carry.d.ts.map +1 -0
- package/dist/internal/testing/carry.js +77 -0
- package/dist/internal/testing/carry.js.map +1 -0
- package/dist/internal/testing/scope.d.ts +34 -6
- package/dist/internal/testing/scope.d.ts.map +1 -1
- package/dist/internal/testing/scope.js +103 -5
- package/dist/internal/testing/scope.js.map +1 -1
- package/dist/internal/testing/steps.d.ts +55 -0
- package/dist/internal/testing/steps.d.ts.map +1 -0
- package/dist/internal/testing/steps.js +295 -0
- package/dist/internal/testing/steps.js.map +1 -0
- package/dist/internal/testing/telemetry.d.ts +305 -0
- package/dist/internal/testing/telemetry.d.ts.map +1 -0
- package/dist/internal/testing/telemetry.js +188 -0
- package/dist/internal/testing/telemetry.js.map +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/pubsub/mod.d.ts +1 -1
- package/dist/pubsub/mod.d.ts.map +1 -1
- package/dist/pubsub/subscription.d.ts +6 -5
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +14 -8
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +36 -22
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +1 -18
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +1 -17
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -1
- package/dist/services/index.js.map +1 -1
- package/dist/storage/objects/bucket.d.ts +2 -1
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +2 -1
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/postgres/database.d.ts +5 -1
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +7 -3
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +5 -5
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +5 -5
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/testing/mod.d.ts +28 -5
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +52 -8
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +93 -0
- package/dist/testing/playwright.d.ts.map +1 -0
- package/dist/testing/playwright.js +164 -0
- package/dist/testing/playwright.js.map +1 -0
- package/dist/testing/puppeteer.d.ts +36 -0
- package/dist/testing/puppeteer.d.ts.map +1 -0
- package/dist/testing/puppeteer.js +70 -0
- package/dist/testing/puppeteer.js.map +1 -0
- package/dist/testing/system.d.ts +181 -0
- package/dist/testing/system.d.ts.map +1 -0
- package/dist/testing/system.js +255 -0
- package/dist/testing/system.js.map +1 -0
- package/dist/tracing/http.d.ts +11 -0
- package/dist/tracing/http.d.ts.map +1 -0
- package/dist/tracing/http.js +34 -0
- package/dist/tracing/http.js.map +1 -0
- package/dist/tracing/mod.d.ts +1 -0
- package/dist/tracing/mod.d.ts.map +1 -1
- package/dist/tracing/mod.js +1 -0
- package/dist/tracing/mod.js.map +1 -1
- package/dist/tracing/node.d.ts +10 -0
- package/dist/tracing/node.d.ts.map +1 -0
- package/dist/tracing/node.js +142 -0
- package/dist/tracing/node.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +51 -0
- package/frontends/mod.ts +50 -0
- package/gateway/mod.ts +3 -2
- package/gateways/mod.ts +60 -0
- package/internal/fetch.ts +12 -1
- package/internal/otel/http.ts +91 -0
- package/internal/otel/index.ts +1 -1
- package/internal/otel/provider.ts +3 -0
- package/internal/otel/span.ts +25 -2
- package/internal/reqfields.ts +43 -10
- package/internal/runtime/napi/napi.cjs +36 -4
- package/internal/runtime/napi/napi.d.cts +99 -4
- package/internal/testing/carry.test.ts +242 -0
- package/internal/testing/carry.ts +101 -0
- package/internal/testing/scope.ts +106 -7
- package/internal/testing/steps.test.ts +152 -0
- package/internal/testing/steps.ts +342 -0
- package/internal/testing/telemetry.test.ts +210 -0
- package/internal/testing/telemetry.ts +466 -0
- package/mod.ts +1 -0
- package/package.json +26 -1
- package/pubsub/mod.ts +6 -1
- package/pubsub/pubsub.test.ts +1 -0
- package/pubsub/subscription.ts +6 -5
- package/pubsub/topic.ts +45 -21
- package/reqctx/mod.ts +1 -18
- package/reqctx/reqctx.test.ts +23 -0
- package/scripts/postprocess-docs.test.ts +11 -1
- package/services/index.ts +2 -1
- package/storage/objects/bucket.ts +2 -1
- package/storage/postgres/database.ts +7 -3
- package/storage/redis/commands.ts +5 -5
- package/testing/mod.ts +63 -7
- package/testing/playwright.ts +247 -0
- package/testing/puppeteer.ts +101 -0
- package/testing/system.test.ts +108 -0
- package/testing/system.ts +373 -0
- package/tracing/http.ts +49 -0
- package/tracing/mod.ts +1 -0
- package/tracing/native.test.ts +101 -4
- package/tracing/node.ts +176 -0
- package/tracing/tracing.test.ts +660 -24
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
export interface AppMeta {
|
|
6
6
|
appId: string
|
|
7
7
|
appSlug: string
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* The API gateways the service is given, keyed by gateway name: those
|
|
10
|
+
* its code names, and the one it hosts.
|
|
11
|
+
*/
|
|
9
12
|
gateways: Record<string, GatewayMeta>
|
|
13
|
+
/**
|
|
14
|
+
* The frontends the service is given, keyed by name: those its code
|
|
15
|
+
* names, and the one it hosts.
|
|
16
|
+
*/
|
|
17
|
+
frontends: Record<string, FrontendMeta>
|
|
10
18
|
environment: EnvironmentMeta
|
|
11
19
|
build: BuildMeta
|
|
12
20
|
deploy: DeployMeta
|
|
@@ -103,7 +111,7 @@ export interface ConfigRevision {
|
|
|
103
111
|
number: number
|
|
104
112
|
/**
|
|
105
113
|
* The value, as JSON text, with a placeholder
|
|
106
|
-
* (`{"$encore_secret":
|
|
114
|
+
* (`{"$encore_secret": "<name>"}`) for each secret field.
|
|
107
115
|
*/
|
|
108
116
|
value: string
|
|
109
117
|
}
|
|
@@ -183,6 +191,12 @@ export interface ExtendRetentionOptions {
|
|
|
183
191
|
version?: string
|
|
184
192
|
}
|
|
185
193
|
|
|
194
|
+
export interface FrontendMeta {
|
|
195
|
+
name: string
|
|
196
|
+
url: string
|
|
197
|
+
origins: Array<string>
|
|
198
|
+
}
|
|
199
|
+
|
|
186
200
|
/**
|
|
187
201
|
* An attribute of a request's edge span: an integer when `integer` is set
|
|
188
202
|
* and `value` a number.
|
|
@@ -232,7 +246,8 @@ export class GatewayHeaders {
|
|
|
232
246
|
|
|
233
247
|
export interface GatewayMeta {
|
|
234
248
|
name: string
|
|
235
|
-
|
|
249
|
+
url: string
|
|
250
|
+
origins: Array<string>
|
|
236
251
|
}
|
|
237
252
|
|
|
238
253
|
/**
|
|
@@ -789,7 +804,11 @@ export class SqlDatabase {
|
|
|
789
804
|
/** Begins a transaction, with `options` if given. */
|
|
790
805
|
begin(options?: SqlTransactionOptions | undefined | null, source?: Buffer | undefined | null): Promise<Transaction>
|
|
791
806
|
query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
|
|
792
|
-
|
|
807
|
+
/**
|
|
808
|
+
* Takes a connection out of the pool, in the context `source` names:
|
|
809
|
+
* the host's active span context, as a query is given it.
|
|
810
|
+
*/
|
|
811
|
+
acquire(source?: Buffer | undefined | null): Promise<SQLConn>
|
|
793
812
|
}
|
|
794
813
|
export type SQLDatabase = SqlDatabase
|
|
795
814
|
|
|
@@ -804,6 +823,43 @@ export interface SqlTransactionOptions {
|
|
|
804
823
|
}
|
|
805
824
|
export type SQLTransactionOptions = SqlTransactionOptions
|
|
806
825
|
|
|
826
|
+
/** The test session a system test's process runs against. */
|
|
827
|
+
export class SystemTest {
|
|
828
|
+
/** The suite the process's tests are of. */
|
|
829
|
+
get suite(): string
|
|
830
|
+
/** The test session's id, as `encore run ls` lists it. */
|
|
831
|
+
get session(): string
|
|
832
|
+
/** The session's service proxy: `/<service>/…` there reaches the service. */
|
|
833
|
+
get proxyUrl(): string
|
|
834
|
+
/**
|
|
835
|
+
* The URL of the gateway or frontend `name` in the session, or null if
|
|
836
|
+
* the app has neither.
|
|
837
|
+
*/
|
|
838
|
+
url(name: string): string | null
|
|
839
|
+
/** The names of the session's gateways, sorted. */
|
|
840
|
+
gateways(): Array<string>
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* What a system test's calls and messages carry of the test, for those
|
|
845
|
+
* whose context does not already hold it.
|
|
846
|
+
*/
|
|
847
|
+
export interface TestCarried {
|
|
848
|
+
/** The name of the Request Context field that holds the test's id. */
|
|
849
|
+
fieldName: string
|
|
850
|
+
/** The field's value, in a field's wire form. */
|
|
851
|
+
field: string
|
|
852
|
+
/**
|
|
853
|
+
* The headers a call made for the test carries, by lowercase name: the
|
|
854
|
+
* field, and the test's span as `traceparent` and `tracestate`.
|
|
855
|
+
*/
|
|
856
|
+
headers: Record<string, string>
|
|
857
|
+
/** The test's span as a `traceparent`, where the process records spans. */
|
|
858
|
+
traceparent?: string
|
|
859
|
+
/** The `tracestate` that goes with it. */
|
|
860
|
+
tracestate?: string
|
|
861
|
+
}
|
|
862
|
+
|
|
807
863
|
/**
|
|
808
864
|
* A message to hand a subscription's handler, and which delivery of it this
|
|
809
865
|
* is: 1 the first time.
|
|
@@ -827,6 +883,40 @@ export interface TestPublished {
|
|
|
827
883
|
export class TestScope {
|
|
828
884
|
/** The scope's id: what its resources are provisioned under. */
|
|
829
885
|
get id(): string
|
|
886
|
+
/**
|
|
887
|
+
* What the test's calls and messages carry of it, when it is a system
|
|
888
|
+
* test: null for a service's test.
|
|
889
|
+
*/
|
|
890
|
+
carried(): TestCarried | null
|
|
891
|
+
/**
|
|
892
|
+
* Resolves once nothing the tests set in motion is still running or
|
|
893
|
+
* queued in the test session, waiting for at most `timeoutMs`, or the
|
|
894
|
+
* core's 30 seconds. Rejects, saying what was still under way, if it did
|
|
895
|
+
* not settle in time, and for a test that is no system test.
|
|
896
|
+
*/
|
|
897
|
+
settled(timeoutMs?: number | undefined | null): Promise<void>
|
|
898
|
+
/**
|
|
899
|
+
* What the test session recorded for the test so far, as the JSON of
|
|
900
|
+
* the core's model (`Telemetry::to_json`): once the session has settled
|
|
901
|
+
* with `settle`, waiting as `settled` does. Rejects for a test that is no
|
|
902
|
+
* system test.
|
|
903
|
+
*/
|
|
904
|
+
telemetry(settle: boolean, timeoutMs?: number | undefined | null): Promise<string>
|
|
905
|
+
/**
|
|
906
|
+
* The test's browser, which the test session runs for it, as JSON
|
|
907
|
+
* (`wsEndpoint`, `urls`, `recording`, `stepsUrl`): started at the first ask, the
|
|
908
|
+
* same one after that. `record` says when what it records is kept
|
|
909
|
+
* (`"failed"`, `"all"` or `"off"`), `args` are more arguments for it,
|
|
910
|
+
* and `width` and `height` its window's size. Rejects for a test that
|
|
911
|
+
* is no system test.
|
|
912
|
+
*/
|
|
913
|
+
browser(record?: string | undefined | null, args?: Array<string> | undefined | null, width?: number | undefined | null, height?: number | undefined | null): Promise<string>
|
|
914
|
+
/**
|
|
915
|
+
* Says how the test ended, for the session to record when the test
|
|
916
|
+
* ends: `"passed"`, `"failed"` or `"skipped"`. Nothing for a test that is
|
|
917
|
+
* no system test.
|
|
918
|
+
*/
|
|
919
|
+
setOutcome(outcome: 'passed' | 'failed' | 'skipped'): void
|
|
830
920
|
/**
|
|
831
921
|
* Ends the test: its resources are released, unless they are a
|
|
832
922
|
* fixture's. Its handles fail from then on.
|
|
@@ -906,6 +996,11 @@ export class TestScopes {
|
|
|
906
996
|
* that publishes to its own topic for ever.
|
|
907
997
|
*/
|
|
908
998
|
get maxDeliveries(): number
|
|
999
|
+
/**
|
|
1000
|
+
* The test session the process's tests run against, when they are
|
|
1001
|
+
* system tests: null for the tests of a service.
|
|
1002
|
+
*/
|
|
1003
|
+
system(): SystemTest | null
|
|
909
1004
|
/**
|
|
910
1005
|
* Asks for the fixture `name`, which starts from the fixture `parent` if
|
|
911
1006
|
* there is one. Resolves to null once it is built — by this process or
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a system test's calls and messages carry of the test: the Request
|
|
3
|
+
* Context field that holds its id, and its span for them to continue, so
|
|
4
|
+
* that what the app does for the test can be told from the rest.
|
|
5
|
+
*
|
|
6
|
+
* Apart from the module that knows the tests (`./scope`), which needs the
|
|
7
|
+
* runtime: what sends calls loads without it, and asks here. Outside a
|
|
8
|
+
* system test nothing is registered, and a context is sent as it is.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
import { type Context } from '@opentelemetry/api';
|
|
13
|
+
/** What one system test's calls and messages carry. */
|
|
14
|
+
export interface Carried {
|
|
15
|
+
/** The name of the Request Context field that holds the test's id. */
|
|
16
|
+
readonly fieldName: string;
|
|
17
|
+
/** The field's value, in a field's wire form. */
|
|
18
|
+
readonly field: string;
|
|
19
|
+
/** The test's span as a `traceparent`, where the process records spans. */
|
|
20
|
+
readonly traceparent?: string | null;
|
|
21
|
+
/** The `tracestate` that goes with it. */
|
|
22
|
+
readonly tracestate?: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Registers how the current system test is found: by `./scope`, in a
|
|
25
|
+
* system test's process only. */
|
|
26
|
+
export declare function setCarriedLookup(fn: (() => Carried | null) | undefined): void;
|
|
27
|
+
/**
|
|
28
|
+
* The context a call or a publish made in `ctx` is made in: in a system
|
|
29
|
+
* test, `ctx` with what the current test carries added where `ctx` has none
|
|
30
|
+
* (see {@link withCarried}). Anywhere else, `ctx` itself.
|
|
31
|
+
*
|
|
32
|
+
* It throws where several tests run at once and none is current: a call
|
|
33
|
+
* sent then would carry no test, and what the app did for it would be done
|
|
34
|
+
* on data no test sees and waited for by none.
|
|
35
|
+
*/
|
|
36
|
+
export declare function outgoingContext(ctx?: Context): Context;
|
|
37
|
+
/**
|
|
38
|
+
* {@link outgoingContext}, for what is recorded or sent elsewhere than to
|
|
39
|
+
* the app: where no test can be told from another, `ctx` itself.
|
|
40
|
+
*/
|
|
41
|
+
export declare function outgoingContextIfKnown(ctx: Context): Context;
|
|
42
|
+
/**
|
|
43
|
+
* `ctx` with what a test carries added where `ctx` has none: the field that
|
|
44
|
+
* holds the test's id, unless `ctx` holds one, as the context of a request
|
|
45
|
+
* made for another test does, and the test's span, unless `ctx` has a span
|
|
46
|
+
* of its own.
|
|
47
|
+
*/
|
|
48
|
+
export declare function withCarried(ctx: Context, carried: Carried): Context;
|
|
49
|
+
//# sourceMappingURL=carry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carry.d.ts","sourceRoot":"","sources":["../../../internal/testing/carry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,oBAAoB,CAAC;AAK5B,uDAAuD;AACvD,MAAM,WAAW,OAAO;IACtB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAOD;iCACiC;AACjC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,CAE7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,OAAyB,GAAG,OAAO,CAIvE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAuBnE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a system test's calls and messages carry of the test: the Request
|
|
3
|
+
* Context field that holds its id, and its span for them to continue, so
|
|
4
|
+
* that what the app does for the test can be told from the rest.
|
|
5
|
+
*
|
|
6
|
+
* Apart from the module that knows the tests (`./scope`), which needs the
|
|
7
|
+
* runtime: what sends calls loads without it, and asks here. Outside a
|
|
8
|
+
* system test nothing is registered, and a context is sent as it is.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
import { createTraceState, isSpanContextValid, trace, } from '@opentelemetry/api';
|
|
13
|
+
import { activeContext } from '../otel/context.js';
|
|
14
|
+
import { parseTraceparent } from '../otel/propagator.js';
|
|
15
|
+
import * as reqfields from '../reqfields.js';
|
|
16
|
+
/** Finds what the current test carries: `null` when there is none. It
|
|
17
|
+
* throws where several tests run at once and none is current, as it cannot
|
|
18
|
+
* tell which one a call belongs to. */
|
|
19
|
+
let lookup;
|
|
20
|
+
/** Registers how the current system test is found: by `./scope`, in a
|
|
21
|
+
* system test's process only. */
|
|
22
|
+
export function setCarriedLookup(fn) {
|
|
23
|
+
lookup = fn;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The context a call or a publish made in `ctx` is made in: in a system
|
|
27
|
+
* test, `ctx` with what the current test carries added where `ctx` has none
|
|
28
|
+
* (see {@link withCarried}). Anywhere else, `ctx` itself.
|
|
29
|
+
*
|
|
30
|
+
* It throws where several tests run at once and none is current: a call
|
|
31
|
+
* sent then would carry no test, and what the app did for it would be done
|
|
32
|
+
* on data no test sees and waited for by none.
|
|
33
|
+
*/
|
|
34
|
+
export function outgoingContext(ctx = activeContext()) {
|
|
35
|
+
if (lookup === undefined)
|
|
36
|
+
return ctx;
|
|
37
|
+
const carried = lookup();
|
|
38
|
+
return carried === null ? ctx : withCarried(ctx, carried);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* {@link outgoingContext}, for what is recorded or sent elsewhere than to
|
|
42
|
+
* the app: where no test can be told from another, `ctx` itself.
|
|
43
|
+
*/
|
|
44
|
+
export function outgoingContextIfKnown(ctx) {
|
|
45
|
+
try {
|
|
46
|
+
return outgoingContext(ctx);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return ctx;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `ctx` with what a test carries added where `ctx` has none: the field that
|
|
54
|
+
* holds the test's id, unless `ctx` holds one, as the context of a request
|
|
55
|
+
* made for another test does, and the test's span, unless `ctx` has a span
|
|
56
|
+
* of its own.
|
|
57
|
+
*/
|
|
58
|
+
export function withCarried(ctx, carried) {
|
|
59
|
+
let out = ctx;
|
|
60
|
+
const fields = reqfields.current(ctx);
|
|
61
|
+
if (!Object.hasOwn(fields, carried.fieldName)) {
|
|
62
|
+
out = reqfields.withFields({ ...fields, [carried.fieldName]: carried.field }, out);
|
|
63
|
+
}
|
|
64
|
+
const span = trace.getSpanContext(ctx);
|
|
65
|
+
if ((span === undefined || !isSpanContextValid(span)) &&
|
|
66
|
+
carried.traceparent) {
|
|
67
|
+
const parent = parseTraceparent(carried.traceparent);
|
|
68
|
+
if (parent !== undefined) {
|
|
69
|
+
if (carried.tracestate) {
|
|
70
|
+
parent.traceState = createTraceState(carried.tracestate);
|
|
71
|
+
}
|
|
72
|
+
out = trace.setSpanContext(out, parent);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=carry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carry.js","sourceRoot":"","sources":["../../../internal/testing/carry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAEN,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAc1C;;uCAEuC;AACvC,IAAI,MAA0C,CAAC;AAE/C;iCACiC;AACjC,MAAM,UAAU,gBAAgB,CAAC,EAAsC;IACrE,MAAM,GAAG,EAAE,CAAC;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAe,aAAa,EAAE;IAC5D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AAC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`encore test` or a test runner. */
|
|
3
3
|
export declare const testMode: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The test session the process's tests run against, when they are system
|
|
6
|
+
* tests, those of a suite: `null` for a service's tests, and outside test
|
|
7
|
+
* mode.
|
|
8
|
+
*/
|
|
9
|
+
export declare const systemTest: runtime.SystemTest | null;
|
|
10
|
+
/** How a test ended, as its runner says. */
|
|
11
|
+
export type Outcome = 'passed' | 'failed' | 'skipped';
|
|
4
12
|
/** One test: the core's scope, and the handles made of it. */
|
|
5
13
|
export declare class Scope {
|
|
6
14
|
readonly native: runtime.TestScope;
|
|
@@ -14,7 +22,20 @@ export declare class Scope {
|
|
|
14
22
|
readonly configs: Map<string, unknown>;
|
|
15
23
|
/** Done with, but left to the hooks that run after the test's own. */
|
|
16
24
|
finished: boolean;
|
|
25
|
+
/** How the test ended, once something has said. */
|
|
26
|
+
private outcome?;
|
|
27
|
+
private carry?;
|
|
17
28
|
constructor(native: runtime.TestScope, name?: string);
|
|
29
|
+
/** What the test's calls and messages carry of it, when it is a system
|
|
30
|
+
* test: `null` for a service's test. */
|
|
31
|
+
get carried(): runtime.TestCarried | null;
|
|
32
|
+
/**
|
|
33
|
+
* Says how a system test ended, for its session to record, and prints
|
|
34
|
+
* what a failed one caused in the app to standard error, under the
|
|
35
|
+
* failure its runner prints. Once per test: the first to say so is the
|
|
36
|
+
* one that saw it end. Nothing for a service's test.
|
|
37
|
+
*/
|
|
38
|
+
ended(outcome: Outcome): Promise<void>;
|
|
18
39
|
/** The test's instance of the database `name`, for `access`. */
|
|
19
40
|
sqlDatabase(name: string, access?: runtime.SQLAccess): runtime.SQLDatabase;
|
|
20
41
|
/** The test's instance of the bucket `name`. */
|
|
@@ -45,8 +66,6 @@ export declare function currentScope(): Scope | null;
|
|
|
45
66
|
export declare function requireScope(): Scope;
|
|
46
67
|
/** The core's scopes, or an error outside test mode. */
|
|
47
68
|
export declare function requireScopes(): runtime.TestScopes;
|
|
48
|
-
/** What a runner calls a hook with: its test context, if it has one. */
|
|
49
|
-
type HookArgs = unknown[];
|
|
50
69
|
/** Whether a hook's argument is its runner's test context: an object, or
|
|
51
70
|
* vitest's, a function with properties. */
|
|
52
71
|
export declare function isContext(ctx: unknown): ctx is object;
|
|
@@ -59,11 +78,18 @@ export declare function hookScope(ctx: unknown): Scope | null;
|
|
|
59
78
|
/** The name of the test a hook runs for, for diagnostics: vitest's and
|
|
60
79
|
* node:test's contexts have it, and jest's and bun's `expect`. */
|
|
61
80
|
export declare function testName(ctx: unknown): string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* How the test of a runner's test context ended, where the context says:
|
|
83
|
+
* vitest's has the test's result once it is done, and node:test's whether it
|
|
84
|
+
* passed. `undefined` where it does not, as in jest and bun, whose hooks are
|
|
85
|
+
* not told.
|
|
86
|
+
*/
|
|
87
|
+
export declare function outcomeOf(ctx: unknown): Outcome | undefined;
|
|
62
88
|
/** A runner's hooks, as `setup` takes them. */
|
|
63
89
|
export interface Hooks {
|
|
64
|
-
beforeEach(fn: (...args:
|
|
65
|
-
afterEach(fn: (...args:
|
|
66
|
-
afterAll?(fn: (...args:
|
|
90
|
+
beforeEach(fn: (...args: unknown[]) => unknown): void;
|
|
91
|
+
afterEach(fn: (...args: unknown[]) => unknown): void;
|
|
92
|
+
afterAll?(fn: (...args: unknown[]) => unknown): void;
|
|
67
93
|
}
|
|
68
94
|
/**
|
|
69
95
|
* Registers per-test scopes with a runner's hooks: a scope begins before each
|
|
@@ -75,7 +101,9 @@ export interface Hooks {
|
|
|
75
101
|
* registers after these, so the scope is only marked done after the test,
|
|
76
102
|
* for the hooks after it to use, and ends when the next test begins or the
|
|
77
103
|
* file's tests are done.
|
|
104
|
+
*
|
|
105
|
+
* A system test is also told how it ended, where the runner's context says
|
|
106
|
+
* ({@link outcomeOf}), and a failed one prints what it caused in the app.
|
|
78
107
|
*/
|
|
79
108
|
export declare function setupHooks(hooks: Hooks, prepare?: (scope: Scope) => Promise<void> | void): void;
|
|
80
|
-
export {};
|
|
81
109
|
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../internal/testing/scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../internal/testing/scope.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAQ1C,gFAAgF;AAChF,eAAO,MAAM,QAAQ,SAAkB,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,UAAU,GAAG,IAA+B,CAAC;AAE9E,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtD,8DAA8D;AAC9D,qBAAa,KAAK;IAChB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0C;IACpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAC7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;IAClE,mEAAmE;IACnE,QAAQ,CAAC,GAAG,cAAqB;IACjC,oEAAoE;IACpE,QAAQ,CAAC,OAAO,uBAA8B;IAC9C,sEAAsE;IACtE,QAAQ,UAAS;IACjB,mDAAmD;IACnD,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,KAAK,CAAC,CAA6B;gBAE/B,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM;IAKpD;4CACwC;IACxC,IAAI,OAAO,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAGxC;IAED;;;;;OAKG;IACG,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5C,gE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AE,KAAK,OAAO,GAAG,IAAI,CAAC;IACtD,SAAS,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;IACrD,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAC/C,IAAI,CA8CN"}
|
|
@@ -9,14 +9,26 @@
|
|
|
9
9
|
* hooks began ({@link setupHooks}). Outside test mode there are no scopes,
|
|
10
10
|
* and every lookup is `null` at once.
|
|
11
11
|
*
|
|
12
|
+
* In a system test's process the tests run against the app's test session
|
|
13
|
+
* ({@link systemTest}): each scope is then a test the session knows, with an
|
|
14
|
+
* id its calls and messages carry ({@link Scope.carried}).
|
|
15
|
+
*
|
|
12
16
|
* @internal
|
|
13
17
|
*/
|
|
14
18
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
15
19
|
import * as runtime from '../runtime/mod.js';
|
|
20
|
+
import { setCarriedLookup } from './carry.js';
|
|
21
|
+
import { causedBy, Telemetry } from './telemetry.js';
|
|
16
22
|
/** The core's scopes: `null` outside test mode. */
|
|
17
23
|
const scopes = runtime.TEST_SCOPES ?? null;
|
|
18
24
|
/** Whether the process runs as a test, under `encore test` or a test runner. */
|
|
19
25
|
export const testMode = scopes !== null;
|
|
26
|
+
/**
|
|
27
|
+
* The test session the process's tests run against, when they are system
|
|
28
|
+
* tests, those of a suite: `null` for a service's tests, and outside test
|
|
29
|
+
* mode.
|
|
30
|
+
*/
|
|
31
|
+
export const systemTest = scopes?.system() ?? null;
|
|
20
32
|
/** One test: the core's scope, and the handles made of it. */
|
|
21
33
|
export class Scope {
|
|
22
34
|
native;
|
|
@@ -30,10 +42,45 @@ export class Scope {
|
|
|
30
42
|
configs = new Map();
|
|
31
43
|
/** Done with, but left to the hooks that run after the test's own. */
|
|
32
44
|
finished = false;
|
|
45
|
+
/** How the test ended, once something has said. */
|
|
46
|
+
outcome;
|
|
47
|
+
carry;
|
|
33
48
|
constructor(native, name) {
|
|
34
49
|
this.native = native;
|
|
35
50
|
this.name = name;
|
|
36
51
|
}
|
|
52
|
+
/** What the test's calls and messages carry of it, when it is a system
|
|
53
|
+
* test: `null` for a service's test. */
|
|
54
|
+
get carried() {
|
|
55
|
+
if (this.carry === undefined)
|
|
56
|
+
this.carry = this.native.carried();
|
|
57
|
+
return this.carry;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Says how a system test ended, for its session to record, and prints
|
|
61
|
+
* what a failed one caused in the app to standard error, under the
|
|
62
|
+
* failure its runner prints. Once per test: the first to say so is the
|
|
63
|
+
* one that saw it end. Nothing for a service's test.
|
|
64
|
+
*/
|
|
65
|
+
async ended(outcome) {
|
|
66
|
+
if (systemTest === null || this.outcome !== undefined)
|
|
67
|
+
return;
|
|
68
|
+
this.outcome = outcome;
|
|
69
|
+
this.native.setOutcome(outcome);
|
|
70
|
+
if (outcome !== 'failed')
|
|
71
|
+
return;
|
|
72
|
+
let caused;
|
|
73
|
+
try {
|
|
74
|
+
// As it is now: a failed test may have left the app at work.
|
|
75
|
+
caused = causedBy(Telemetry.parse(await this.native.telemetry(false, null)));
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// The test's own failure is what there is to say.
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (caused !== '')
|
|
82
|
+
console.error(caused);
|
|
83
|
+
}
|
|
37
84
|
/** The test's instance of the database `name`, for `access`. */
|
|
38
85
|
sqlDatabase(name, access) {
|
|
39
86
|
let db = this.databases.get(name);
|
|
@@ -158,6 +205,8 @@ function endFinished() {
|
|
|
158
205
|
}
|
|
159
206
|
/** The scope the hooks began for the test of a runner's test context. */
|
|
160
207
|
const byContext = new WeakMap();
|
|
208
|
+
/** The scopes that end with their runner's `onTestFinished`. */
|
|
209
|
+
const endsItself = new WeakSet();
|
|
161
210
|
/** Whether a hook's argument is its runner's test context: an object, or
|
|
162
211
|
* vitest's, a function with properties. */
|
|
163
212
|
export function isContext(ctx) {
|
|
@@ -186,6 +235,36 @@ export function testName(ctx) {
|
|
|
186
235
|
? state.currentTestName
|
|
187
236
|
: undefined;
|
|
188
237
|
}
|
|
238
|
+
if (systemTest !== null) {
|
|
239
|
+
// A call or a publish carries the test it is made for, found as a
|
|
240
|
+
// resource finds its test. Where several tests run at once and none is
|
|
241
|
+
// current, it cannot be told which, and the lookup throws as a resource's
|
|
242
|
+
// does: a call made without the test would be done on data no test sees.
|
|
243
|
+
setCarriedLookup(() => lookupScope()?.carried ?? null);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* How the test of a runner's test context ended, where the context says:
|
|
247
|
+
* vitest's has the test's result once it is done, and node:test's whether it
|
|
248
|
+
* passed. `undefined` where it does not, as in jest and bun, whose hooks are
|
|
249
|
+
* not told.
|
|
250
|
+
*/
|
|
251
|
+
export function outcomeOf(ctx) {
|
|
252
|
+
if (!isContext(ctx))
|
|
253
|
+
return undefined;
|
|
254
|
+
const c = ctx;
|
|
255
|
+
switch (c.task?.result?.state) {
|
|
256
|
+
case 'pass':
|
|
257
|
+
return 'passed';
|
|
258
|
+
case 'fail':
|
|
259
|
+
return 'failed';
|
|
260
|
+
case 'skip':
|
|
261
|
+
case 'todo':
|
|
262
|
+
return 'skipped';
|
|
263
|
+
}
|
|
264
|
+
if (typeof c.passed === 'boolean')
|
|
265
|
+
return c.passed ? 'passed' : 'failed';
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
189
268
|
/**
|
|
190
269
|
* Registers per-test scopes with a runner's hooks: a scope begins before each
|
|
191
270
|
* test and ends after it. `prepare` runs in each test's scope after it
|
|
@@ -196,6 +275,9 @@ export function testName(ctx) {
|
|
|
196
275
|
* registers after these, so the scope is only marked done after the test,
|
|
197
276
|
* for the hooks after it to use, and ends when the next test begins or the
|
|
198
277
|
* file's tests are done.
|
|
278
|
+
*
|
|
279
|
+
* A system test is also told how it ended, where the runner's context says
|
|
280
|
+
* ({@link outcomeOf}), and a failed one prints what it caused in the app.
|
|
199
281
|
*/
|
|
200
282
|
export function setupHooks(hooks, prepare) {
|
|
201
283
|
if (scopes === null)
|
|
@@ -212,9 +294,17 @@ export function setupHooks(hooks, prepare) {
|
|
|
212
294
|
byContext.set(ctx, scope);
|
|
213
295
|
const onFinished = ctx.onTestFinished;
|
|
214
296
|
if (typeof onFinished === 'function') {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
297
|
+
endsItself.add(scope);
|
|
298
|
+
onFinished.call(ctx, async () => {
|
|
299
|
+
try {
|
|
300
|
+
const outcome = outcomeOf(ctx);
|
|
301
|
+
if (outcome !== undefined)
|
|
302
|
+
await scope.ended(outcome);
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
hooked.delete(scope);
|
|
306
|
+
scope.end();
|
|
307
|
+
}
|
|
218
308
|
});
|
|
219
309
|
}
|
|
220
310
|
}
|
|
@@ -229,8 +319,16 @@ export function setupHooks(hooks, prepare) {
|
|
|
229
319
|
const scope = isContext(ctx)
|
|
230
320
|
? byContext.get(ctx)
|
|
231
321
|
: [...hooked].find(scope => !scope.finished);
|
|
232
|
-
if (scope
|
|
233
|
-
|
|
322
|
+
if (scope === undefined || !hooked.has(scope))
|
|
323
|
+
return undefined;
|
|
324
|
+
scope.finished = true;
|
|
325
|
+
// A scope that ends itself says how its test ended then, once the
|
|
326
|
+
// hooks after this one have run. Any other says so now, while the
|
|
327
|
+
// failure is what the runner prints next.
|
|
328
|
+
if (endsItself.has(scope))
|
|
329
|
+
return undefined;
|
|
330
|
+
const outcome = outcomeOf(ctx);
|
|
331
|
+
return outcome === undefined ? undefined : scope.ended(outcome);
|
|
234
332
|
});
|
|
235
333
|
hooks.afterAll?.(() => endFinished());
|
|
236
334
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../internal/testing/scope.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../internal/testing/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAEhD,mDAAmD;AACnD,MAAM,MAAM,GACT,OAAqD,CAAC,WAAW,IAAI,IAAI,CAAC;AAE7E,gFAAgF;AAChF,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,KAAK,IAAI,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAA8B,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC;AAK9E,8DAA8D;AAC9D,MAAM,OAAO,KAAK;IACP,MAAM,CAAoB;IAC1B,IAAI,CAAqB;IACjB,SAAS,GAAG,IAAI,GAAG,EAA+B,CAAC;IACnD,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC5C,KAAK,GAAG,IAAI,GAAG,EAAiC,CAAC;IAClE,mEAAmE;IAC1D,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,oEAAoE;IAC3D,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,sEAAsE;IACtE,QAAQ,GAAG,KAAK,CAAC;IACjB,mDAAmD;IAC3C,OAAO,CAAW;IAClB,KAAK,CAA8B;IAE3C,YAAY,MAAyB,EAAE,IAAa;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI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+
/**
|
|
2
|
+
* Says which statement of a test is running while it has its browser do
|
|
3
|
+
* something, for the adapters of `@encore.dev/sdk/testing`.
|
|
4
|
+
*
|
|
5
|
+
* A test's browser is reached through Encore, which reads what the test's
|
|
6
|
+
* tool has it do — a click, a key, a navigation — off the protocol. That
|
|
7
|
+
* says what was done, not which line of the test did it. So each call the
|
|
8
|
+
* test makes on its tool's objects is reported as a **step**, with the call
|
|
9
|
+
* as written and where it is, on the connection the tool's own commands go
|
|
10
|
+
* over: what the browser is told between a step's beginning and its end is
|
|
11
|
+
* that statement's doing.
|
|
12
|
+
*
|
|
13
|
+
* The tool's objects are wrapped ({@link wrap}), not changed: a call on a
|
|
14
|
+
* wrapper reports the step and makes the call on the object itself.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
/** Sends a command of Encore's own over a tool's connection to the browser. */
|
|
19
|
+
export type Send = (method: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
20
|
+
/** Reports steps over a connection. */
|
|
21
|
+
export declare class Steps {
|
|
22
|
+
private readonly send;
|
|
23
|
+
/** Set once the connection has failed: nothing more is reported. */
|
|
24
|
+
private gone;
|
|
25
|
+
constructor(send: Send);
|
|
26
|
+
/** Runs `fn` as the step `name`, made at `at`. */
|
|
27
|
+
run<R>(name: string, at: Location | null, fn: () => R): Promise<Awaited<R>>;
|
|
28
|
+
/**
|
|
29
|
+
* Says the step `name` begins, now: the word is on its way before this
|
|
30
|
+
* returns, ahead of whatever the caller has the browser do next. Resolves
|
|
31
|
+
* to the step's id, or `null` where nothing took it.
|
|
32
|
+
*/
|
|
33
|
+
begin(name: string, at: Location | null): Promise<string | null>;
|
|
34
|
+
/** Says the step `step` ended, with `error` if it failed. */
|
|
35
|
+
end(step: Promise<string | null>, error?: string): Promise<void>;
|
|
36
|
+
/** Takes back the step `step`: what began was no statement of its own. */
|
|
37
|
+
discard(step: Promise<string | null>): Promise<void>;
|
|
38
|
+
private finish;
|
|
39
|
+
}
|
|
40
|
+
/** Where in the test a call was made. */
|
|
41
|
+
export interface Location {
|
|
42
|
+
file: string;
|
|
43
|
+
line: number;
|
|
44
|
+
}
|
|
45
|
+
/** Where the test called from: the first frame of the stack that is its own. */
|
|
46
|
+
export declare function caller(): Location | null;
|
|
47
|
+
/** The tool's own object for `value`, if `value` is a wrapper of one. */
|
|
48
|
+
export declare function unwrap<T>(value: T): T;
|
|
49
|
+
/**
|
|
50
|
+
* Wraps `target`, an object of a test's tool, so that each call made on it
|
|
51
|
+
* is reported to `steps`: `label` is what it is called in a step's name
|
|
52
|
+
* (`page`, or the call that gave it, as `page.locator("#pay")`).
|
|
53
|
+
*/
|
|
54
|
+
export declare function wrap<T extends object>(target: T, label: string, steps: Steps): T;
|
|
55
|
+
//# sourceMappingURL=steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../../internal/testing/steps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,+EAA+E;AAC/E,MAAM,MAAM,IAAI,GAAG,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,uCAAuC;AACvC,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,oEAAoE;IACpE,OAAO,CAAC,IAAI,CAAS;gBAET,IAAI,EAAE,IAAI;IAItB,kDAAkD;IAC5C,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,QAAQ,GAAG,IAAI,EACnB,EAAE,EAAE,MAAM,CAAC,GACV,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAYtB;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,MA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