@livestore/utils-dev 0.4.0-dev.9 → 0.5.0-dev.0
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/dist/.tsbuildinfo +1 -0
- package/dist/node/DockerCompose/DockerCompose.d.ts +52 -0
- package/dist/node/DockerCompose/DockerCompose.d.ts.map +1 -0
- package/dist/node/DockerCompose/DockerCompose.js +158 -0
- package/dist/node/DockerCompose/DockerCompose.js.map +1 -0
- package/dist/node/DockerCompose/DockerCompose.test.d.ts +2 -0
- package/dist/node/DockerCompose/DockerCompose.test.d.ts.map +1 -0
- package/dist/node/{DockerComposeService/DockerComposeService.test.js → DockerCompose/DockerCompose.test.js} +18 -18
- package/dist/node/DockerCompose/DockerCompose.test.js.map +1 -0
- package/dist/node/DockerCompose/mod.d.ts +2 -0
- package/dist/node/DockerCompose/mod.d.ts.map +1 -0
- package/dist/node/DockerCompose/mod.js +2 -0
- package/dist/node/DockerCompose/mod.js.map +1 -0
- package/dist/node/FileLogger.d.ts +15 -8
- package/dist/node/FileLogger.d.ts.map +1 -1
- package/dist/node/FileLogger.js +64 -80
- package/dist/node/FileLogger.js.map +1 -1
- package/dist/node/cmd-log.d.ts +21 -0
- package/dist/node/cmd-log.d.ts.map +1 -0
- package/dist/node/cmd-log.js +58 -0
- package/dist/node/cmd-log.js.map +1 -0
- package/dist/node/cmd.d.ts +20 -14
- package/dist/node/cmd.d.ts.map +1 -1
- package/dist/node/cmd.js +248 -33
- package/dist/node/cmd.js.map +1 -1
- package/dist/node/cmd.test.d.ts +2 -0
- package/dist/node/cmd.test.d.ts.map +1 -0
- package/dist/node/cmd.test.js +103 -0
- package/dist/node/cmd.test.js.map +1 -0
- package/dist/node/mod.d.ts +5 -5
- package/dist/node/mod.d.ts.map +1 -1
- package/dist/node/mod.js +114 -66
- package/dist/node/mod.js.map +1 -1
- package/dist/node/workspace.d.ts +22 -0
- package/dist/node/workspace.d.ts.map +1 -0
- package/dist/node/workspace.js +26 -0
- package/dist/node/workspace.js.map +1 -0
- package/dist/node-vitest/Vitest.d.ts +17 -8
- package/dist/node-vitest/Vitest.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.js +16 -16
- package/dist/node-vitest/Vitest.js.map +1 -1
- package/dist/node-vitest/Vitest.test.d.ts +6 -0
- package/dist/node-vitest/Vitest.test.d.ts.map +1 -1
- package/dist/node-vitest/Vitest.test.js +25 -10
- package/dist/node-vitest/Vitest.test.js.map +1 -1
- package/dist/wrangler/WranglerDevServer.d.ts +32 -20
- package/dist/wrangler/WranglerDevServer.d.ts.map +1 -1
- package/dist/wrangler/WranglerDevServer.js +79 -60
- package/dist/wrangler/WranglerDevServer.js.map +1 -1
- package/dist/wrangler/WranglerDevServer.test.js +31 -31
- package/dist/wrangler/WranglerDevServer.test.js.map +1 -1
- package/dist/wrangler/mod.d.ts +1 -1
- package/dist/wrangler/mod.d.ts.map +1 -1
- package/dist/wrangler/mod.js +1 -1
- package/dist/wrangler/mod.js.map +1 -1
- package/package.json +56 -21
- package/src/node/{DockerComposeService/DockerComposeService.test.ts → DockerCompose/DockerCompose.test.ts} +23 -20
- package/src/node/DockerCompose/DockerCompose.ts +328 -0
- package/src/node/DockerCompose/mod.ts +1 -0
- package/src/node/DockerCompose/test-fixtures/docker-compose.yml +4 -0
- package/src/node/FileLogger.ts +91 -115
- package/src/node/cmd-log.ts +95 -0
- package/src/node/cmd.test.ts +136 -0
- package/src/node/cmd.ts +431 -82
- package/src/node/mod.ts +152 -96
- package/src/node/workspace.ts +45 -0
- package/src/node-vitest/Vitest.test.ts +34 -10
- package/src/node-vitest/Vitest.ts +60 -66
- package/src/wrangler/WranglerDevServer.test.ts +38 -40
- package/src/wrangler/WranglerDevServer.ts +165 -108
- package/src/wrangler/fixtures/wrangler.toml +1 -1
- package/src/wrangler/mod.ts +1 -6
- package/dist/.tsbuildinfo.json +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.d.ts +0 -58
- package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.js +0 -144
- package/dist/node/DockerComposeService/DockerComposeService.js.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.test.d.ts +0 -2
- package/dist/node/DockerComposeService/DockerComposeService.test.d.ts.map +0 -1
- package/dist/node/DockerComposeService/DockerComposeService.test.js.map +0 -1
- package/src/node/DockerComposeService/DockerComposeService.ts +0 -328
- package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +0 -4
package/dist/node/mod.js
CHANGED
|
@@ -1,91 +1,87 @@
|
|
|
1
1
|
import { performance } from 'node:perf_hooks';
|
|
2
|
-
import * as OtelNodeSdk from '@effect/opentelemetry/NodeSdk';
|
|
3
|
-
import { IS_BUN, isNonEmptyString } from '@livestore/utils';
|
|
4
|
-
import { Config, Effect, FiberRef, Layer, LogLevel, OtelTracer } from '@livestore/utils/effect';
|
|
5
|
-
import { OtelLiveDummy } from '@livestore/utils/node';
|
|
6
2
|
import * as otel from '@opentelemetry/api';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
3
|
+
import { IS_BUN } from '@livestore/utils';
|
|
4
|
+
import { Config, Context, Effect, Exit, FetchHttpClient, Layer, Option, OtelTracer, Otlp, Schema, } from '@livestore/utils/effect';
|
|
5
|
+
import { OtelLiveDummy } from '@livestore/utils/node';
|
|
11
6
|
export { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
|
|
12
7
|
export { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
13
8
|
export * from "./cmd.js";
|
|
14
|
-
export
|
|
9
|
+
export * from "./DockerCompose/mod.js";
|
|
15
10
|
export * as FileLogger from "./FileLogger.js";
|
|
11
|
+
export * from "./workspace.js";
|
|
16
12
|
export const OtelLiveHttp = ({ serviceName, rootSpanName, rootSpanAttributes, parentSpan, skipLogUrl, traceNodeBootstrap, } = {}) => Effect.gen(function* () {
|
|
17
13
|
const configRes = yield* Config.all({
|
|
18
|
-
exporterUrl: Config.
|
|
19
|
-
serviceName: serviceName
|
|
14
|
+
exporterUrl: Config.nonEmptyString('OTEL_EXPORTER_OTLP_ENDPOINT'),
|
|
15
|
+
serviceName: serviceName !== undefined
|
|
20
16
|
? Config.succeed(serviceName)
|
|
21
17
|
: Config.string('OTEL_SERVICE_NAME').pipe(Config.withDefault('livestore-utils-dev')),
|
|
22
|
-
rootSpanName: rootSpanName
|
|
18
|
+
rootSpanName: rootSpanName !== undefined
|
|
23
19
|
? Config.succeed(rootSpanName)
|
|
24
20
|
: Config.string('OTEL_ROOT_SPAN_NAME').pipe(Config.withDefault('RootSpan')),
|
|
25
21
|
}).pipe(Effect.option);
|
|
26
22
|
if (configRes._tag === 'None') {
|
|
27
23
|
const RootSpanLive = Layer.span('DummyRoot', {});
|
|
28
|
-
return RootSpanLive.pipe(Layer.provideMerge(OtelLiveDummy));
|
|
24
|
+
return withTracerReference(RootSpanLive.pipe(Layer.provideMerge(OtelLiveDummy)));
|
|
29
25
|
}
|
|
30
26
|
const config = configRes.value;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
metricReader,
|
|
39
|
-
spanProcessor: new BatchSpanProcessor(new OTLPTraceExporter({ url: `${config.exporterUrl}/v1/traces`, headers: {} }), { scheduledDelayMillis: 50 }),
|
|
40
|
-
})).pipe(
|
|
41
|
-
// If an OpenTelemetry backend is not available, the `OtelNodeSdk` layer
|
|
42
|
-
// will ignore the error when attempting to connect and emit a debug log
|
|
43
|
-
// stating the reason for the error (in this case `ECONNREFUSED`). This
|
|
44
|
-
// can cause problems for programs which rely on clean `stdout` (e.g.
|
|
45
|
-
// command-line applications). To remedy this, the below code sets the
|
|
46
|
-
// minimum log level `FiberRef` to `"None"` for the duration of the
|
|
47
|
-
// `OtelNodeSdk`'s layer constructor.
|
|
48
|
-
//
|
|
49
|
-
// This can likely be removed when Livestore is migrated to the Effect
|
|
50
|
-
// native Otlp exporters.
|
|
51
|
-
Layer.locally(FiberRef.currentMinimumLogLevel, LogLevel.None));
|
|
27
|
+
const OtelLive = Otlp.layerJson({
|
|
28
|
+
baseUrl: config.exporterUrl,
|
|
29
|
+
metricsExportInterval: 1000,
|
|
30
|
+
tracerExportInterval: 50,
|
|
31
|
+
resource: { serviceName: config.serviceName },
|
|
32
|
+
}).pipe(Layer.provide(FetchHttpClient.layer));
|
|
33
|
+
const OtelTracerLive = Layer.succeed(OtelTracer.OtelTracer, otel.trace.getTracer(config.serviceName));
|
|
52
34
|
const RootSpanLive = Layer.span(config.rootSpanName, {
|
|
53
35
|
attributes: { config, ...rootSpanAttributes },
|
|
54
|
-
onEnd: skipLogUrl ? undefined : (span) =>
|
|
36
|
+
onEnd: skipLogUrl === true ? undefined : (span) => logTraceUiUrlForTraceId()(span.traceId),
|
|
55
37
|
parent: parentSpan,
|
|
56
38
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
39
|
+
const baseLayer = RootSpanLive.pipe(Layer.provideMerge(Layer.mergeAll(OtelLive, OtelTracerLive)));
|
|
40
|
+
const memoMap = yield* Layer.makeMemoMap;
|
|
41
|
+
const layer = Layer.fromBuild((_, scope) => Layer.buildWithMemoMap(baseLayer, memoMap, scope));
|
|
42
|
+
if (traceNodeBootstrap === true && IS_BUN === false) {
|
|
59
43
|
/**
|
|
60
44
|
* Create a span representing the Node.js bootstrap duration.
|
|
45
|
+
* Note: Skipped in Bun since performance.nodeTiming is not properly supported.
|
|
61
46
|
*/
|
|
62
47
|
yield* Effect.gen(function* () {
|
|
63
|
-
const tracer = yield*
|
|
64
|
-
const currentSpan = yield*
|
|
65
|
-
const nodeTiming =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
48
|
+
const tracer = yield* Effect.tracer;
|
|
49
|
+
const currentSpan = yield* Effect.currentSpan;
|
|
50
|
+
const { nodeTiming, endAbs, durationAttr } = computeBootstrapTiming();
|
|
51
|
+
const bootSpan = tracer.span({
|
|
52
|
+
name: 'node-bootstrap',
|
|
53
|
+
parent: Option.some(currentSpan),
|
|
54
|
+
annotations: Context.empty(),
|
|
55
|
+
links: [],
|
|
56
|
+
startTime: millisToNanos(IS_BUN === true && typeof nodeTiming.nodeStart === 'number'
|
|
57
|
+
? nodeTiming.nodeStart
|
|
58
|
+
: performance.timeOrigin + nodeTiming.nodeStart),
|
|
59
|
+
kind: 'internal',
|
|
60
|
+
root: false,
|
|
61
|
+
sampled: true,
|
|
62
|
+
});
|
|
63
|
+
for (const [key, value] of Object.entries({
|
|
64
|
+
'node.timing.nodeStart': nodeTiming.nodeStart,
|
|
65
|
+
'node.timing.environment': nodeTiming.environment,
|
|
66
|
+
'node.timing.bootstrapComplete': nodeTiming.bootstrapComplete,
|
|
67
|
+
'node.timing.loopStart': nodeTiming.loopStart,
|
|
68
|
+
'node.timing.duration': durationAttr,
|
|
69
|
+
})) {
|
|
70
|
+
if (value !== undefined)
|
|
71
|
+
bootSpan.attribute(key, value);
|
|
72
|
+
}
|
|
73
|
+
bootSpan.end(millisToNanos(endAbs), Exit.void);
|
|
79
74
|
}).pipe(Effect.provide(layer), Effect.orDie);
|
|
80
75
|
}
|
|
81
|
-
return layer;
|
|
82
|
-
}).pipe(Layer.
|
|
83
|
-
export const logTraceUiUrlForSpan = (printMsg) => (span) =>
|
|
76
|
+
return withTracerReference(layer);
|
|
77
|
+
}).pipe(Layer.unwrap);
|
|
78
|
+
export const logTraceUiUrlForSpan = (printMsg) => (span) => logTraceUiUrlForTraceId(printMsg)(span.spanContext().traceId);
|
|
79
|
+
const logTraceUiUrlForTraceId = (printMsg) => (traceId) => getTracingBackendUrl(traceId).pipe(Effect.tap((url) => {
|
|
84
80
|
if (url === undefined) {
|
|
85
81
|
return Effect.logWarning('No tracing backend url found');
|
|
86
82
|
}
|
|
87
83
|
else {
|
|
88
|
-
if (printMsg) {
|
|
84
|
+
if (printMsg !== undefined) {
|
|
89
85
|
return Effect.log(printMsg(url));
|
|
90
86
|
}
|
|
91
87
|
else {
|
|
@@ -93,22 +89,74 @@ export const logTraceUiUrlForSpan = (printMsg) => (span) => getTracingBackendUrl
|
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
}));
|
|
96
|
-
export const getTracingBackendUrl = (
|
|
97
|
-
const endpoint = yield* Config.string('GRAFANA_ENDPOINT').pipe(Config.option
|
|
92
|
+
export const getTracingBackendUrl = (traceIdOrSpan) => Effect.gen(function* () {
|
|
93
|
+
const endpoint = yield* Config.string('GRAFANA_ENDPOINT').pipe(Config.option);
|
|
98
94
|
if (endpoint._tag === 'None')
|
|
99
95
|
return;
|
|
100
|
-
const traceId =
|
|
96
|
+
const traceId = typeof traceIdOrSpan === 'string' ? traceIdOrSpan : traceIdOrSpan.spanContext().traceId;
|
|
101
97
|
// Grafana + Tempo
|
|
102
98
|
const grafanaEndpoint = endpoint.value;
|
|
99
|
+
const left = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown))({
|
|
100
|
+
datasource: 'tempo',
|
|
101
|
+
queries: [{ query: traceId, queryType: 'traceql', refId: 'A' }],
|
|
102
|
+
range: { from: 'now-1h', to: 'now' },
|
|
103
|
+
});
|
|
103
104
|
const searchParams = new URLSearchParams({
|
|
104
105
|
orgId: '1',
|
|
105
|
-
left
|
|
106
|
-
datasource: 'tempo',
|
|
107
|
-
queries: [{ query: traceId, queryType: 'traceql', refId: 'A' }],
|
|
108
|
-
range: { from: 'now-1h', to: 'now' },
|
|
109
|
-
}),
|
|
106
|
+
left,
|
|
110
107
|
});
|
|
111
108
|
// TODO make dynamic via env var
|
|
112
109
|
return `${grafanaEndpoint}/explore?${searchParams.toString()}`;
|
|
113
|
-
});
|
|
110
|
+
}).pipe(Effect.orDie);
|
|
111
|
+
/**
|
|
112
|
+
* Compute absolute start/end timestamps for the Node.js bootstrap span in a
|
|
113
|
+
* way that works in both Node and Bun.
|
|
114
|
+
*
|
|
115
|
+
* Context: Bun's perf_hooks PerformanceNodeTiming currently throws when
|
|
116
|
+
* accessing standard PerformanceEntry getters like `startTime` and
|
|
117
|
+
* `duration`, and some fields differ in semantics (e.g. `nodeStart` appears
|
|
118
|
+
* as an epoch timestamp rather than an offset). See:
|
|
119
|
+
* https://github.com/oven-sh/bun/issues/23041
|
|
120
|
+
*
|
|
121
|
+
* We therefore avoid the problematic getters and derive absolute timestamps
|
|
122
|
+
* using fields that exist in both runtimes.
|
|
123
|
+
*
|
|
124
|
+
* TODO: Simplify to a single, non-branching computation once the Bun issue
|
|
125
|
+
* above is fixed and Bun matches Node's semantics for PerformanceNodeTiming.
|
|
126
|
+
*/
|
|
127
|
+
const computeBootstrapTiming = () => {
|
|
128
|
+
const nodeTiming = performance.nodeTiming;
|
|
129
|
+
// Absolute start time in ms since epoch.
|
|
130
|
+
const startAbs = IS_BUN === true
|
|
131
|
+
? typeof nodeTiming.nodeStart === 'number'
|
|
132
|
+
? nodeTiming.nodeStart
|
|
133
|
+
: performance.timeOrigin
|
|
134
|
+
: performance.timeOrigin + nodeTiming.nodeStart;
|
|
135
|
+
// Absolute end time.
|
|
136
|
+
const endAbs = IS_BUN === true
|
|
137
|
+
? (() => {
|
|
138
|
+
const { loopStart, bootstrapComplete } = nodeTiming;
|
|
139
|
+
if (typeof loopStart === 'number' && loopStart > 0)
|
|
140
|
+
return startAbs + loopStart;
|
|
141
|
+
if (typeof bootstrapComplete === 'number' && bootstrapComplete >= startAbs)
|
|
142
|
+
return bootstrapComplete;
|
|
143
|
+
return startAbs + 1;
|
|
144
|
+
})()
|
|
145
|
+
: startAbs + nodeTiming.duration;
|
|
146
|
+
// Duration attribute value for the span.
|
|
147
|
+
const durationAttr = IS_BUN === true
|
|
148
|
+
? (() => {
|
|
149
|
+
const { loopStart } = nodeTiming;
|
|
150
|
+
return typeof loopStart === 'number' && loopStart > 0 ? loopStart : 0;
|
|
151
|
+
})()
|
|
152
|
+
: nodeTiming.duration;
|
|
153
|
+
return { nodeTiming, startAbs, endAbs, durationAttr };
|
|
154
|
+
};
|
|
155
|
+
const millisToNanos = (millis) => BigInt(Math.round(millis * 1_000_000));
|
|
156
|
+
/**
|
|
157
|
+
* Effect v4 installs `Tracer.Tracer` through a `Context.Reference` fiber ref.
|
|
158
|
+
* The OTEL layers set that reference at runtime, but their layer output type is
|
|
159
|
+
* `never`, so we localize the public compatibility assertion here.
|
|
160
|
+
*/
|
|
161
|
+
const withTracerReference = (layer) => layer;
|
|
114
162
|
//# sourceMappingURL=mod.js.map
|
package/dist/node/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/node/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAEL,MAAM,EACN,OAAO,EACP,MAAM,EACN,IAAI,EACJ,eAAe,EACf,KAAK,EACL,MAAM,EACN,UAAU,EACV,IAAI,EACJ,MAAM,GACP,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAA;AAC3E,cAAc,UAAU,CAAA;AACxB,cAAc,wBAAw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G,EAAE;YACJ,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAA;YACnD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,GAAG,CAAC;gBAAE,OAAO,QAAQ,GAAG,SAAS,CAAA;YAC/E,IAAI,OAAO,iBAAiB,KAAK,QAAQ,IAAI,iBAAiB,IAAI,QAAQ;gBAAE,OAAO,iBAAiB,CAAA;YACpG,OAAO,QAAQ,GAAG,CAAC,CAAA;QACrB,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAA;IAEpC,yCAAyC;IACzC,MAAM,YAAY,GAChB,MAAM,KAAK,IAAI;QACb,CAAC,CAAC,CAAC,GAAG,EAAE;YACJ,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;YAChC,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;QACvE,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAA;IAEzB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAW,CAAA;AAChE,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;AAExF;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,CAC1B,KAAgC,EACW,EAAE,CAAC,KAAkD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Context, Layer } from '@livestore/utils/effect';
|
|
2
|
+
export type WorkspaceInfo = string;
|
|
3
|
+
declare const CurrentWorkingDirectory_base: Context.ServiceClass<CurrentWorkingDirectory, "CurrentWorkingDirectory", string>;
|
|
4
|
+
/** Current working directory. */
|
|
5
|
+
export declare class CurrentWorkingDirectory extends CurrentWorkingDirectory_base {
|
|
6
|
+
/** Layer that captures the process cwd once. */
|
|
7
|
+
static live: Layer.Layer<CurrentWorkingDirectory, never, never>;
|
|
8
|
+
/** Override CWD for tests or nested invocations. */
|
|
9
|
+
static fromPath: (cwd: string) => Layer.Layer<CurrentWorkingDirectory, never, never>;
|
|
10
|
+
}
|
|
11
|
+
declare const LivestoreWorkspace_base: Context.ServiceClass<LivestoreWorkspace, "LivestoreWorkspace", string>;
|
|
12
|
+
/** Livestore workspace root (env required). */
|
|
13
|
+
export declare class LivestoreWorkspace extends LivestoreWorkspace_base {
|
|
14
|
+
/** Resolve from WORKSPACE_ROOT env. */
|
|
15
|
+
static live: Layer.Layer<LivestoreWorkspace, never, never>;
|
|
16
|
+
/** Provide a fixed Livestore root. */
|
|
17
|
+
static fromPath: (root: string) => Layer.Layer<LivestoreWorkspace, never, never>;
|
|
18
|
+
/** Derive a CurrentWorkingDirectory layer from the Livestore workspace root (with optional subpath) */
|
|
19
|
+
static toCwd: (/** Relative path to the Livestore workspace root */ subPath?: string) => Layer.Layer<CurrentWorkingDirectory, never, LivestoreWorkspace>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/node/workspace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAEhE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAA;;AAElC,iCAAiC;AACjC,qBAAa,uBAAwB,SAAQ,4BAE5C;IACC,gDAAgD;IAChD,MAAM,CAAC,IAAI,qDAGV;IAED,oDAAoD;IACpD,MAAM,CAAC,QAAQ,GAAI,KAAK,MAAM,wDAA4E;CAC3G;;AAED,+CAA+C;AAC/C,qBAAa,kBAAmB,SAAQ,uBAA0E;IAChH,uCAAuC;IACvC,MAAM,CAAC,IAAI,gDAMV;IAED,sCAAsC;IACtC,MAAM,CAAC,QAAQ,GAAI,MAAM,MAAM,mDAAmE;IAElG,uGAAuG;IACvG,MAAM,CAAC,KAAK,GAAI,oDAAoD,CAAC,UAAU,MAAM,qEAOlF;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { shouldNeverHappen } from '@livestore/utils';
|
|
3
|
+
import { Context, Effect, Layer } from '@livestore/utils/effect';
|
|
4
|
+
/** Current working directory. */
|
|
5
|
+
export class CurrentWorkingDirectory extends Context.Service()('CurrentWorkingDirectory') {
|
|
6
|
+
/** Layer that captures the process cwd once. */
|
|
7
|
+
static live = Layer.effect(CurrentWorkingDirectory, Effect.sync(() => CurrentWorkingDirectory.of(process.cwd())));
|
|
8
|
+
/** Override CWD for tests or nested invocations. */
|
|
9
|
+
static fromPath = (cwd) => Layer.succeed(CurrentWorkingDirectory, CurrentWorkingDirectory.of(cwd));
|
|
10
|
+
}
|
|
11
|
+
/** Livestore workspace root (env required). */
|
|
12
|
+
export class LivestoreWorkspace extends Context.Service()('LivestoreWorkspace') {
|
|
13
|
+
/** Resolve from WORKSPACE_ROOT env. */
|
|
14
|
+
static live = Layer.effect(LivestoreWorkspace, Effect.sync(() => {
|
|
15
|
+
const root = process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set');
|
|
16
|
+
return LivestoreWorkspace.of(root);
|
|
17
|
+
}));
|
|
18
|
+
/** Provide a fixed Livestore root. */
|
|
19
|
+
static fromPath = (root) => Layer.succeed(LivestoreWorkspace, LivestoreWorkspace.of(root));
|
|
20
|
+
/** Derive a CurrentWorkingDirectory layer from the Livestore workspace root (with optional subpath) */
|
|
21
|
+
static toCwd = (/** Relative path to the Livestore workspace root */ subPath) => Layer.effect(CurrentWorkingDirectory, Effect.gen(function* () {
|
|
22
|
+
const root = yield* LivestoreWorkspace;
|
|
23
|
+
return CurrentWorkingDirectory.of(path.join(root, subPath ?? ''));
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/node/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAIhE,iCAAiC;AACjC,MAAM,OAAO,uBAAwB,SAAQ,OAAO,CAAC,OAAO,EAA0C,CACpG,yBAAyB,CAC1B;IACC,gDAAgD;IAChD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CACxB,uBAAuB,EACvB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAC7D,CAAA;IAED,oDAAoD;IACpD,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;;AAG5G,+CAA+C;AAC/C,MAAM,OAAO,kBAAmB,SAAQ,OAAO,CAAC,OAAO,EAAqC,CAAC,oBAAoB,CAAC;IAChH,uCAAuC;IACvC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CACxB,kBAAkB,EAClB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,iBAAiB,CAAC,2BAA2B,CAAC,CAAA;QACzF,OAAO,kBAAkB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC,CAAC,CACH,CAAA;IAED,sCAAsC;IACtC,MAAM,CAAC,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAElG,uGAAuG;IACvG,MAAM,CAAC,KAAK,GAAG,CAAC,oDAAoD,CAAC,OAAgB,EAAE,EAAE,CACvF,KAAK,CAAC,MAAM,CACV,uBAAuB,EACvB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,kBAAkB,CAAA;QACtC,OAAO,uBAAuB,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,CAAA;IACnE,CAAC,CAAC,CACH,CAAA"}
|
|
@@ -2,19 +2,21 @@ import type * as Vitest from '@effect/vitest';
|
|
|
2
2
|
import { type Cause, Duration, Effect, type FastCheck as FC, Layer, type OtelTracer, type Schema, type Scope } from '@livestore/utils/effect';
|
|
3
3
|
export * from '@effect/vitest';
|
|
4
4
|
export declare const DEBUGGER_ACTIVE: boolean;
|
|
5
|
-
|
|
5
|
+
type WithoutTestCtxServices<R> = Exclude<Exclude<R, OtelTracer.OtelTracer>, Scope.Scope>;
|
|
6
|
+
type WithoutLayerAndTestCtxServices<R, ROut> = Exclude<Exclude<R, ROut | OtelTracer.OtelTracer>, Scope.Scope>;
|
|
7
|
+
export declare const makeWithTestCtx: <ROut = never, E1 = never, RIn = never>(ctxParams: WithTestCtxParams<ROut, E1, RIn>) => (testContext: Vitest.TestContext) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1 | Cause.TimeoutError, WithoutTestCtxServices<RIn> | WithoutLayerAndTestCtxServices<R, ROut>>;
|
|
6
8
|
export type WithTestCtxParams<ROut, E1, RIn> = {
|
|
7
9
|
suffix?: string;
|
|
8
10
|
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn | Scope.Scope>;
|
|
9
|
-
timeout?: Duration.
|
|
11
|
+
timeout?: Duration.Input;
|
|
10
12
|
forceOtel?: boolean;
|
|
11
13
|
};
|
|
12
14
|
export declare const withTestCtx: <ROut = never, E1 = never, RIn = never>(testContext: Vitest.TestContext, { suffix, makeLayer, timeout, forceOtel, }?: {
|
|
13
15
|
suffix?: string;
|
|
14
|
-
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn>;
|
|
15
|
-
timeout?: Duration.
|
|
16
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn | Scope.Scope>;
|
|
17
|
+
timeout?: Duration.Input;
|
|
16
18
|
forceOtel?: boolean;
|
|
17
|
-
}) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1 | Cause.
|
|
19
|
+
}) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E1 | Cause.TimeoutError, WithoutTestCtxServices<RIn> | WithoutLayerAndTestCtxServices<R, ROut>>;
|
|
18
20
|
/**
|
|
19
21
|
* Shared properties for all enhanced test context phases
|
|
20
22
|
*/
|
|
@@ -35,6 +37,15 @@ export type EnhancedTestContext = (EnhancedTestContextBase & {
|
|
|
35
37
|
/** Number of shrinking attempts */
|
|
36
38
|
shrinkAttempt: number;
|
|
37
39
|
});
|
|
40
|
+
/**
|
|
41
|
+
* Normalizes propOptions to ensure @effect/vitest receives correct fastCheck structure
|
|
42
|
+
*/
|
|
43
|
+
type ArbitraryValues<Arbs extends Vitest.Vitest.Arbitraries> = {
|
|
44
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never;
|
|
45
|
+
};
|
|
46
|
+
type PropOptions<Arbs extends Vitest.Vitest.Arbitraries> = Omit<Vitest.TestOptions, 'fastCheck'> & {
|
|
47
|
+
fastCheck?: FC.Parameters<ArbitraryValues<Arbs>>;
|
|
48
|
+
};
|
|
38
49
|
/**
|
|
39
50
|
* Equivalent to Vitest.prop but provides enhanced context including shrinking progress visibility
|
|
40
51
|
*
|
|
@@ -46,7 +57,5 @@ export type EnhancedTestContext = (EnhancedTestContextBase & {
|
|
|
46
57
|
*
|
|
47
58
|
* TODO: Upstream to Effect
|
|
48
59
|
*/
|
|
49
|
-
export declare const asProp: <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(api: Vitest.Vitest.Tester<R>, name: string, arbitraries: Arbs, test: Vitest.Vitest.TestFunction<A, E, R, [
|
|
50
|
-
fastCheck?: FC.Parameters<{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>; }>;
|
|
51
|
-
})) => void;
|
|
60
|
+
export declare const asProp: <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(api: Vitest.Vitest.Tester<R>, name: string, arbitraries: Arbs, test: Vitest.Vitest.TestFunction<A, E, R, [ArbitraryValues<Arbs>, Vitest.TestContext, EnhancedTestContext]>, propOptions: number | PropOptions<Arbs>) => void;
|
|
52
61
|
//# sourceMappingURL=Vitest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Vitest.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAG7C,OAAO,EACL,KAAK,KAAK,EACV,QAAQ,EACR,MAAM,EACN,KAAK,SAAS,IAAI,EAAE,EAEpB,KAAK,EACL,KAAK,UAAU,EAEf,KAAK,MAAM,EACX,KAAK,KAAK,EACX,MAAM,yBAAyB,CAAA;AAKhC,cAAc,gBAAgB,CAAA;AAE9B,eAAO,MAAM,eAAe,SAAwE,CAAA;AAEpG,KAAK,sBAAsB,CAAC,CAAC,IAAI,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,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CAClH,CAAA;AAED,KAAK,WAAW,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG;IACjG,SAAS,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAA;CACjD,CAAA;AAoCD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EACpE,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAC5B,MAAM,MAAM,EACZ,aAAa,IAAI,EACjB,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,EAC3G,aAAa,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,SA2CxC,CAAA"}
|
|
@@ -6,41 +6,41 @@ import { OtelLiveHttp } from "../node/mod.js";
|
|
|
6
6
|
export * from '@effect/vitest';
|
|
7
7
|
export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined);
|
|
8
8
|
export const makeWithTestCtx = (ctxParams) => (testContext) => withTestCtx(testContext, ctxParams);
|
|
9
|
-
export const withTestCtx = (testContext, { suffix, makeLayer, timeout = IS_CI ? 60_000 : 10_000, forceOtel = false, } = {}) => (self) => {
|
|
10
|
-
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`;
|
|
9
|
+
export const withTestCtx = (testContext, { suffix, makeLayer, timeout = IS_CI === true ? 60_000 : 10_000, forceOtel = false, } = {}) => (self) => {
|
|
10
|
+
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix !== undefined ? `:${suffix}` : ''}`;
|
|
11
|
+
// `Layer.empty` provides `never`, which is narrower than an arbitrary generic
|
|
12
|
+
// `ROut`; widen it for the no-layer branch so `Effect.provide` can typecheck.
|
|
11
13
|
const layer = makeLayer?.(testContext) ?? Layer.empty;
|
|
12
|
-
const
|
|
14
|
+
const timeoutDuration = Duration.fromInputUnsafe(timeout);
|
|
15
|
+
const otelLayer = DEBUGGER_ACTIVE === true || forceOtel === true
|
|
13
16
|
? OtelLiveHttp({ rootSpanName: spanName, serviceName: 'vitest-runner', skipLogUrl: false })
|
|
14
17
|
: OtelLiveDummy;
|
|
15
18
|
const combinedLayer = layer.pipe(Layer.provideMerge(otelLayer));
|
|
16
|
-
return self.pipe(DEBUGGER_ACTIVE
|
|
19
|
+
return self.pipe(DEBUGGER_ACTIVE === true
|
|
17
20
|
? identity
|
|
18
21
|
: Effect.logWarnIfTakesLongerThan({
|
|
19
|
-
duration: Duration.toMillis(
|
|
20
|
-
label: `${spanName} approaching timeout (timeout: ${Duration.format(
|
|
21
|
-
}), DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout), Effect.provide(combinedLayer), Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
22
|
+
duration: Duration.toMillis(timeoutDuration) * 0.8,
|
|
23
|
+
label: `${spanName} approaching timeout (timeout: ${Duration.format(timeoutDuration)})`,
|
|
24
|
+
}), DEBUGGER_ACTIVE === true ? identity : Effect.timeout(timeout), Effect.provide(combinedLayer), Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
22
25
|
Effect.annotateLogs({ suffix }));
|
|
23
26
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Normalizes propOptions to ensure @effect/vitest receives correct fastCheck structure
|
|
26
|
-
*/
|
|
27
27
|
const normalizePropOptions = (propOptions) => {
|
|
28
28
|
// If it's a number, treat as timeout and add our default fastCheck
|
|
29
|
-
if (
|
|
29
|
+
if (Predicate.isObject(propOptions) === false) {
|
|
30
30
|
return {
|
|
31
31
|
timeout: propOptions,
|
|
32
32
|
fastCheck: { numRuns: 100 },
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
// If no fastCheck property, add it with our default numRuns
|
|
36
|
-
if (
|
|
36
|
+
if (propOptions.fastCheck == null) {
|
|
37
37
|
return {
|
|
38
38
|
...propOptions,
|
|
39
39
|
fastCheck: { numRuns: 100 },
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
// If fastCheck exists but no numRuns, add our default
|
|
43
|
-
if (propOptions.fastCheck &&
|
|
43
|
+
if (propOptions.fastCheck !== undefined && propOptions.fastCheck.numRuns == null) {
|
|
44
44
|
return {
|
|
45
45
|
...propOptions,
|
|
46
46
|
fastCheck: {
|
|
@@ -70,15 +70,15 @@ export const asProp = (api, name, arbitraries, test, propOptions) => {
|
|
|
70
70
|
let shrinkAttempts = 0;
|
|
71
71
|
let totalExecutions = 0;
|
|
72
72
|
return api.prop(name, arbitraries, (properties, ctx) => {
|
|
73
|
-
if (ctx.signal.aborted) {
|
|
73
|
+
if (ctx.signal.aborted === true) {
|
|
74
74
|
return ctx.skip('Test aborted');
|
|
75
75
|
}
|
|
76
76
|
totalExecutions++;
|
|
77
77
|
const isInShrinkingPhase = runIndex >= numRuns;
|
|
78
|
-
if (isInShrinkingPhase) {
|
|
78
|
+
if (isInShrinkingPhase === true) {
|
|
79
79
|
shrinkAttempts++;
|
|
80
80
|
}
|
|
81
|
-
const enhancedContext = isInShrinkingPhase
|
|
81
|
+
const enhancedContext = isInShrinkingPhase === true
|
|
82
82
|
? {
|
|
83
83
|
_tag: 'shrinking',
|
|
84
84
|
numRuns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;
|
|
1
|
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ACzB,CAAC,CAAC;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO;gBACP,QAAQ,EAAE,QAAQ,EAAE;gBACpB,aAAa,EAAE,cAAc;gBAC7B,eAAe;aAChB;YACH,CAAC,CAAC;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO;gBACP,QAAQ,EAAE,QAAQ,EAAE;gBACpB,eAAe;aAChB,CAAA;QAEP,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,eAAe,CAAC,CAAA;IAC/C,CAAC,EACD,qBAAqB,CACtB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import { Schema } from '@livestore/utils/effect';
|
|
2
|
+
declare const TestError_base: Schema.Class<TestError, Schema.TaggedStruct<"TestError", {
|
|
3
|
+
readonly message: Schema.String;
|
|
4
|
+
}>, import("effect/Cause").YieldableError>;
|
|
5
|
+
export declare class TestError extends TestError_base {
|
|
6
|
+
}
|
|
1
7
|
export {};
|
|
2
8
|
//# sourceMappingURL=Vitest.test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.test.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Vitest.test.d.ts","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,yBAAyB,CAAA;;;;AAInE,qBAAa,SAAU,SAAQ,cAE7B;CAAG"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { Effect, FastCheck } from '@livestore/utils/effect';
|
|
1
|
+
import { Effect, FastCheck, Schema } from '@livestore/utils/effect';
|
|
2
2
|
import * as Vitest from "./Vitest.js";
|
|
3
|
+
export class TestError extends Schema.TaggedError()('TestError', {
|
|
4
|
+
message: Schema.String,
|
|
5
|
+
}) {
|
|
6
|
+
}
|
|
3
7
|
// Demonstrate enhanced asProp functionality with clear shrinking progress
|
|
4
8
|
// This showcases the fix for the "Run 26/6" bug and accurate shrinking detection
|
|
5
9
|
Vitest.describe('Vitest.asProp', () => {
|
|
6
10
|
const IntArbitrary = FastCheck.integer({ min: 1, max: 100 });
|
|
7
11
|
// Always-passing test - should only show initial phase
|
|
8
|
-
Vitest.asProp(Vitest.
|
|
12
|
+
Vitest.asProp(Vitest.live, 'always-pass test (shows only initial runs)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
|
|
9
13
|
const [value] = properties;
|
|
10
14
|
if (value === undefined) {
|
|
11
|
-
return yield*
|
|
15
|
+
return yield* new TestError({ message: 'Value is undefined' });
|
|
12
16
|
}
|
|
13
17
|
console.log(`✅ ALWAYS-PASS [${enhanced._tag.toUpperCase()}]: ` +
|
|
14
18
|
(enhanced._tag === 'initial'
|
|
@@ -18,12 +22,23 @@ Vitest.describe('Vitest.asProp', () => {
|
|
|
18
22
|
// This test always passes, so no shrinking will occur
|
|
19
23
|
return;
|
|
20
24
|
}), { fastCheck: { numRuns: 4 } });
|
|
25
|
+
Vitest.asProp(Vitest.live, 'converts record-form schemas to arbitraries', {
|
|
26
|
+
count: Schema.Int,
|
|
27
|
+
payload: Schema.Struct({
|
|
28
|
+
label: Schema.String,
|
|
29
|
+
note: Schema.optional(Schema.String),
|
|
30
|
+
}),
|
|
31
|
+
}, ({ count, payload }) => Effect.sync(() => {
|
|
32
|
+
Vitest.expect(Number.isInteger(count)).toBe(true);
|
|
33
|
+
Vitest.expect(typeof payload.label).toBe('string');
|
|
34
|
+
Vitest.expect(payload.note === undefined || typeof payload.note === 'string').toBe(true);
|
|
35
|
+
}), { fastCheck: { numRuns: 10 } });
|
|
21
36
|
// Failing test - should show initial + shrinking phases
|
|
22
37
|
let alreadyFailed = false;
|
|
23
|
-
Vitest.asProp(Vitest.
|
|
38
|
+
Vitest.asProp(Vitest.live, 'failing test (shows initial runs + shrinking)', [IntArbitrary], (properties, ctx, enhanced) => Effect.gen(function* () {
|
|
24
39
|
const [value] = properties;
|
|
25
40
|
if (value === undefined) {
|
|
26
|
-
return yield*
|
|
41
|
+
return yield* new TestError({ message: 'Value is undefined' });
|
|
27
42
|
}
|
|
28
43
|
const displayInfo = enhanced._tag === 'initial'
|
|
29
44
|
? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
|
|
@@ -33,25 +48,25 @@ Vitest.describe('Vitest.asProp', () => {
|
|
|
33
48
|
// Fail when value is greater than 80 to trigger shrinking
|
|
34
49
|
if (value > 80) {
|
|
35
50
|
alreadyFailed = true;
|
|
36
|
-
return yield*
|
|
51
|
+
return yield* new TestError({ message: `Value ${value} is too large (> 80)` });
|
|
37
52
|
}
|
|
38
|
-
if (alreadyFailed && enhanced._tag === 'shrinking') {
|
|
53
|
+
if (alreadyFailed === true && enhanced._tag === 'shrinking') {
|
|
39
54
|
ctx.skip("For the sake of this test, we don't want to fail but want to skip");
|
|
40
55
|
return;
|
|
41
56
|
}
|
|
42
57
|
return;
|
|
43
58
|
}), { fastCheck: { numRuns: 3 } });
|
|
44
59
|
// Test with endOnFailure: true - should not show shrinking
|
|
45
|
-
Vitest.asProp(Vitest.
|
|
60
|
+
Vitest.asProp(Vitest.live, 'failing test with endOnFailure (no shrinking)', [IntArbitrary], (properties, _ctx, enhanced) => Effect.gen(function* () {
|
|
46
61
|
const [value] = properties;
|
|
47
62
|
if (value === undefined) {
|
|
48
|
-
return yield*
|
|
63
|
+
return yield* new TestError({ message: 'Value is undefined' });
|
|
49
64
|
}
|
|
50
65
|
console.log(`🚫 END-ON-FAILURE [${enhanced._tag.toUpperCase()}]: ` +
|
|
51
66
|
`Run ${enhanced.runIndex + 1}/${enhanced.numRuns}, value=${value}, total=${enhanced.totalExecutions}`);
|
|
52
67
|
// This will fail but shrinking is disabled
|
|
53
68
|
if (value > 50) {
|
|
54
|
-
yield*
|
|
69
|
+
return yield* new TestError({ message: `Value ${value} is too large (> 50) - but no shrinking!` });
|
|
55
70
|
}
|
|
56
71
|
return;
|
|
57
72
|
}), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vitest.test.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"Vitest.test.js","sourceRoot":"","sources":["../../src/node-vitest/Vitest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,WAAW,EAAa,CAAC,WAAW,EAAE;IAC1E,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL,0EAA0E;AAC1E,iFAAiF;AAEjF,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IACpC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;IAE5D,uDAAuD;IACvD,MAAM,CAAC,MAAM,CACX,MAAM,CAAC,IAAI,EACX,4CAA4C,EAC5C,CAAC,YAAY,CAAC,EACd,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,CAC7B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClB,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,CAAA;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;QAChE,CAAC;QAED,OAAO,CAAC,GAAG,CACT,kBAAkB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK;YAChD,CAAC,QAAQ,C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