@livestore/utils-dev 0.4.0-dev.3 → 0.4.0-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/.tsbuildinfo.json +1 -1
  2. package/dist/node/DockerComposeService/DockerComposeService.d.ts +48 -0
  3. package/dist/node/DockerComposeService/DockerComposeService.d.ts.map +1 -0
  4. package/dist/node/DockerComposeService/DockerComposeService.js +107 -0
  5. package/dist/node/DockerComposeService/DockerComposeService.js.map +1 -0
  6. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts +2 -0
  7. package/dist/node/DockerComposeService/DockerComposeService.test.d.ts.map +1 -0
  8. package/dist/node/DockerComposeService/DockerComposeService.test.js +64 -0
  9. package/dist/node/DockerComposeService/DockerComposeService.test.js.map +1 -0
  10. package/dist/node/WranglerDevServer/WranglerDevServer.d.ts +52 -0
  11. package/dist/node/WranglerDevServer/WranglerDevServer.d.ts.map +1 -0
  12. package/dist/node/WranglerDevServer/WranglerDevServer.js +122 -0
  13. package/dist/node/WranglerDevServer/WranglerDevServer.js.map +1 -0
  14. package/dist/node/WranglerDevServer/WranglerDevServer.test.d.ts +2 -0
  15. package/dist/node/WranglerDevServer/WranglerDevServer.test.d.ts.map +1 -0
  16. package/dist/node/WranglerDevServer/WranglerDevServer.test.js +179 -0
  17. package/dist/node/WranglerDevServer/WranglerDevServer.test.js.map +1 -0
  18. package/dist/node/WranglerDevServer/fixtures/cf-worker.d.ts +8 -0
  19. package/dist/node/WranglerDevServer/fixtures/cf-worker.d.ts.map +1 -0
  20. package/dist/node/WranglerDevServer/fixtures/cf-worker.js +11 -0
  21. package/dist/node/WranglerDevServer/fixtures/cf-worker.js.map +1 -0
  22. package/dist/node/WranglerDevServer/process-tree-manager.d.ts +55 -0
  23. package/dist/node/WranglerDevServer/process-tree-manager.d.ts.map +1 -0
  24. package/dist/node/WranglerDevServer/process-tree-manager.js +178 -0
  25. package/dist/node/WranglerDevServer/process-tree-manager.js.map +1 -0
  26. package/dist/node/cmd.d.ts +27 -0
  27. package/dist/node/cmd.d.ts.map +1 -0
  28. package/dist/node/cmd.js +55 -0
  29. package/dist/node/cmd.js.map +1 -0
  30. package/dist/node/mod.d.ts +6 -26
  31. package/dist/node/mod.d.ts.map +1 -1
  32. package/dist/node/mod.js +6 -54
  33. package/dist/node/mod.js.map +1 -1
  34. package/dist/node/vitest-docker-compose-setup.d.ts +32 -0
  35. package/dist/node/vitest-docker-compose-setup.d.ts.map +1 -0
  36. package/dist/node/vitest-docker-compose-setup.js +131 -0
  37. package/dist/node/vitest-docker-compose-setup.js.map +1 -0
  38. package/dist/node/vitest-wrangler-setup.d.ts +27 -0
  39. package/dist/node/vitest-wrangler-setup.d.ts.map +1 -0
  40. package/dist/node/vitest-wrangler-setup.js +96 -0
  41. package/dist/node/vitest-wrangler-setup.js.map +1 -0
  42. package/dist/node-vitest/Vitest.d.ts +37 -3
  43. package/dist/node-vitest/Vitest.d.ts.map +1 -1
  44. package/dist/node-vitest/Vitest.js +81 -4
  45. package/dist/node-vitest/Vitest.js.map +1 -1
  46. package/dist/node-vitest/Vitest.test.d.ts +2 -0
  47. package/dist/node-vitest/Vitest.test.d.ts.map +1 -0
  48. package/dist/node-vitest/Vitest.test.js +59 -0
  49. package/dist/node-vitest/Vitest.test.js.map +1 -0
  50. package/package.json +7 -9
  51. package/src/node/DockerComposeService/DockerComposeService.test.ts +91 -0
  52. package/src/node/DockerComposeService/DockerComposeService.ts +252 -0
  53. package/src/node/DockerComposeService/test-fixtures/docker-compose.yml +4 -0
  54. package/src/node/WranglerDevServer/WranglerDevServer.test.ts +266 -0
  55. package/src/node/WranglerDevServer/WranglerDevServer.ts +266 -0
  56. package/src/node/WranglerDevServer/fixtures/cf-worker.ts +11 -0
  57. package/src/node/WranglerDevServer/fixtures/wrangler.toml +11 -0
  58. package/src/node/WranglerDevServer/process-tree-manager.ts +263 -0
  59. package/src/node/cmd.ts +99 -0
  60. package/src/node/mod.ts +20 -111
  61. package/src/node-vitest/Vitest.test.ts +101 -0
  62. package/src/node-vitest/Vitest.ts +173 -9
package/src/node/mod.ts CHANGED
@@ -1,19 +1,9 @@
1
1
  import { performance } from 'node:perf_hooks'
2
2
 
3
3
  import * as OtelNodeSdk from '@effect/opentelemetry/NodeSdk'
4
- import { IS_BUN, isNonEmptyString, isNotUndefined, shouldNeverHappen } from '@livestore/utils'
5
- import type { CommandExecutor, PlatformError, Tracer } from '@livestore/utils/effect'
6
- import {
7
- Command,
8
- Config,
9
- Effect,
10
- FiberRef,
11
- identity,
12
- Layer,
13
- LogLevel,
14
- OtelTracer,
15
- Schema,
16
- } from '@livestore/utils/effect'
4
+ import { IS_BUN, isNonEmptyString } from '@livestore/utils'
5
+ import type { Tracer } from '@livestore/utils/effect'
6
+ import { Config, Effect, FiberRef, Layer, LogLevel, OtelTracer } from '@livestore/utils/effect'
17
7
  import { OtelLiveDummy } from '@livestore/utils/node'
18
8
  import * as otel from '@opentelemetry/api'
19
9
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
@@ -23,8 +13,24 @@ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'
23
13
 
24
14
  export { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
25
15
  export { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
26
-
16
+ export * from './cmd.ts'
17
+ export {
18
+ type DockerComposeArgs,
19
+ DockerComposeError,
20
+ type DockerComposeOperations,
21
+ DockerComposeService,
22
+ type LogsOptions,
23
+ type StartOptions,
24
+ startDockerComposeServicesScoped,
25
+ } from './DockerComposeService/DockerComposeService.ts'
27
26
  export * as FileLogger from './FileLogger.ts'
27
+ export * from './WranglerDevServer/process-tree-manager.ts'
28
+ export {
29
+ type StartWranglerDevServerArgs,
30
+ type WranglerDevServer,
31
+ WranglerDevServerError,
32
+ WranglerDevServerService,
33
+ } from './WranglerDevServer/WranglerDevServer.ts'
28
34
 
29
35
  export const OtelLiveHttp = ({
30
36
  serviceName,
@@ -169,100 +175,3 @@ export const getTracingBackendUrl = (span: otel.Span) =>
169
175
  // TODO make dynamic via env var
170
176
  return `${grafanaEndpoint}/explore?${searchParams.toString()}`
171
177
  })
172
-
173
- export const cmd: (
174
- commandInput: string | (string | undefined)[],
175
- options?:
176
- | {
177
- cwd?: string
178
- stderr?: 'inherit' | 'pipe'
179
- stdout?: 'inherit' | 'pipe'
180
- shell?: boolean
181
- env?: Record<string, string | undefined>
182
- }
183
- | undefined,
184
- ) => Effect.Effect<CommandExecutor.ExitCode, PlatformError.PlatformError | CmdError, CommandExecutor.CommandExecutor> =
185
- Effect.fn('cmd')(function* (commandInput, options) {
186
- const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set')
187
- const [command, ...args] = Array.isArray(commandInput)
188
- ? commandInput.filter(isNotUndefined)
189
- : commandInput.split(' ')
190
-
191
- const debugEnvStr = Object.entries(options?.env ?? {})
192
- .map(([key, value]) => `${key}='${value}' `)
193
- .join('')
194
- const subshellStr = options?.shell ? ' (in subshell)' : ''
195
- const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
196
-
197
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`)
198
- yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, cwd, command, args })
199
-
200
- return yield* Command.make(command!, ...args).pipe(
201
- // TODO don't forward abort signal to the command
202
- Command.stdin('inherit'), // Forward stdin to the command
203
- // inherit = Stream stdout to process.stdout, pipe = Stream stdout to process.stderr
204
- Command.stdout(options?.stdout ?? 'inherit'),
205
- // inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
206
- Command.stderr(options?.stderr ?? 'inherit'),
207
- Command.workingDirectory(cwd),
208
- options?.shell ? Command.runInShell(true) : identity,
209
- Command.env(options?.env ?? {}),
210
- Command.exitCode,
211
- Effect.tap((exitCode) =>
212
- exitCode === 0
213
- ? Effect.void
214
- : Effect.fail(
215
- CmdError.make({
216
- command: command!,
217
- args,
218
- cwd,
219
- env: options?.env ?? {},
220
- stderr: options?.stderr ?? 'inherit',
221
- }),
222
- ),
223
- ),
224
- )
225
- })
226
-
227
- export const cmdText: (
228
- commandInput: string | (string | undefined)[],
229
- options?: {
230
- cwd?: string
231
- stderr?: 'inherit' | 'pipe'
232
- runInShell?: boolean
233
- env?: Record<string, string | undefined>
234
- },
235
- ) => Effect.Effect<string, PlatformError.PlatformError, CommandExecutor.CommandExecutor> = Effect.fn('cmdText')(
236
- function* (commandInput, options) {
237
- const cwd = options?.cwd ?? process.env.WORKSPACE_ROOT ?? shouldNeverHappen('WORKSPACE_ROOT is not set')
238
- const [command, ...args] = Array.isArray(commandInput)
239
- ? commandInput.filter(isNotUndefined)
240
- : commandInput.split(' ')
241
- const debugEnvStr = Object.entries(options?.env ?? {})
242
- .map(([key, value]) => `${key}='${value}' `)
243
- .join('')
244
-
245
- const commandDebugStr = debugEnvStr + [command, ...args].join(' ')
246
- const subshellStr = options?.runInShell ? ' (in subshell)' : ''
247
-
248
- yield* Effect.logDebug(`Running '${commandDebugStr}' in '${cwd}'${subshellStr}`)
249
- yield* Effect.annotateCurrentSpan({ 'span.label': commandDebugStr, command, cwd })
250
-
251
- return yield* Command.make(command!, ...args).pipe(
252
- // inherit = Stream stderr to process.stderr, pipe = Stream stderr to process.stdout
253
- Command.stderr(options?.stderr ?? 'inherit'),
254
- Command.workingDirectory(cwd),
255
- options?.runInShell ? Command.runInShell(true) : identity,
256
- Command.env(options?.env ?? {}),
257
- Command.string,
258
- )
259
- },
260
- )
261
-
262
- export class CmdError extends Schema.TaggedError<CmdError>()('CmdError', {
263
- command: Schema.String,
264
- args: Schema.Array(Schema.String),
265
- cwd: Schema.String,
266
- env: Schema.Record({ key: Schema.String, value: Schema.String.pipe(Schema.UndefinedOr) }),
267
- stderr: Schema.Literal('inherit', 'pipe'),
268
- }) {}
@@ -0,0 +1,101 @@
1
+ import { Effect, FastCheck } from '@livestore/utils/effect'
2
+ import * as Vitest from './Vitest.ts'
3
+
4
+ // Demonstrate enhanced asProp functionality with clear shrinking progress
5
+ // This showcases the fix for the "Run 26/6" bug and accurate shrinking detection
6
+
7
+ Vitest.describe('Vitest.asProp', () => {
8
+ const IntArbitrary = FastCheck.integer({ min: 1, max: 100 })
9
+
10
+ // Always-passing test - should only show initial phase
11
+ Vitest.asProp(
12
+ Vitest.scopedLive,
13
+ 'always-pass test (shows only initial runs)',
14
+ [IntArbitrary],
15
+ (properties, _ctx, enhanced) =>
16
+ Effect.gen(function* () {
17
+ const [value] = properties
18
+ if (value === undefined) {
19
+ return yield* Effect.fail(new Error('Value is undefined'))
20
+ }
21
+
22
+ console.log(
23
+ `✅ ALWAYS-PASS [${enhanced._tag.toUpperCase()}]: ` +
24
+ (enhanced._tag === 'initial'
25
+ ? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
26
+ : `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`) +
27
+ `, value=${value}, total=${enhanced.totalExecutions}`,
28
+ )
29
+
30
+ // This test always passes, so no shrinking will occur
31
+ return
32
+ }),
33
+ { fastCheck: { numRuns: 4 } },
34
+ )
35
+
36
+ // Failing test - should show initial + shrinking phases
37
+ let alreadyFailed = false
38
+ Vitest.asProp(
39
+ Vitest.scopedLive,
40
+ 'failing test (shows initial runs + shrinking)',
41
+ [IntArbitrary],
42
+ (properties, ctx, enhanced) =>
43
+ Effect.gen(function* () {
44
+ const [value] = properties
45
+ if (value === undefined) {
46
+ return yield* Effect.fail(new Error('Value is undefined'))
47
+ }
48
+
49
+ const displayInfo =
50
+ enhanced._tag === 'initial'
51
+ ? `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}`
52
+ : `Shrink #${enhanced.shrinkAttempt} (finding minimal counterexample)`
53
+
54
+ const status = value > 80 ? '💥' : '✅'
55
+ console.log(
56
+ `${status} FAILING-TEST [${enhanced._tag.toUpperCase()}]: ${displayInfo}, value=${value}, total=${enhanced.totalExecutions}`,
57
+ )
58
+
59
+ // Fail when value is greater than 80 to trigger shrinking
60
+ if (value > 80) {
61
+ alreadyFailed = true
62
+ return yield* Effect.fail(new Error(`Value ${value} is too large (> 80)`))
63
+ }
64
+
65
+ if (alreadyFailed && enhanced._tag === 'shrinking') {
66
+ ctx.skip("For the sake of this test, we don't want to fail but want to skip")
67
+ return
68
+ }
69
+
70
+ return
71
+ }),
72
+ { fastCheck: { numRuns: 3 } },
73
+ )
74
+
75
+ // Test with endOnFailure: true - should not show shrinking
76
+ Vitest.asProp(
77
+ Vitest.scopedLive,
78
+ 'failing test with endOnFailure (no shrinking)',
79
+ [IntArbitrary],
80
+ (properties, _ctx, enhanced) =>
81
+ Effect.gen(function* () {
82
+ const [value] = properties
83
+ if (value === undefined) {
84
+ return yield* Effect.fail(new Error('Value is undefined'))
85
+ }
86
+
87
+ console.log(
88
+ `🚫 END-ON-FAILURE [${enhanced._tag.toUpperCase()}]: ` +
89
+ `Run ${enhanced.runIndex + 1}/${enhanced.numRuns}, value=${value}, total=${enhanced.totalExecutions}`,
90
+ )
91
+
92
+ // This will fail but shrinking is disabled
93
+ if (value > 50) {
94
+ yield* Effect.fail(new Error(`Value ${value} is too large (> 50) - but no shrinking!`))
95
+ }
96
+
97
+ return
98
+ }),
99
+ { fastCheck: { numRuns: 5, endOnFailure: true }, fails: true },
100
+ )
101
+ })
@@ -1,7 +1,18 @@
1
1
  import * as inspector from 'node:inspector'
2
2
  import type * as Vitest from '@effect/vitest'
3
3
  import { IS_CI } from '@livestore/utils'
4
- import { type Cause, Duration, Effect, identity, Layer, type OtelTracer, type Scope } from '@livestore/utils/effect'
4
+ import {
5
+ type Cause,
6
+ Duration,
7
+ Effect,
8
+ type FastCheck as FC,
9
+ identity,
10
+ Layer,
11
+ type OtelTracer,
12
+ Predicate,
13
+ type Schema,
14
+ type Scope,
15
+ } from '@livestore/utils/effect'
5
16
  import { OtelLiveDummy } from '@livestore/utils/node'
6
17
  import { OtelLiveHttp } from '../node/mod.ts'
7
18
 
@@ -9,12 +20,17 @@ export * from '@effect/vitest'
9
20
 
10
21
  export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined)
11
22
 
12
- export const makeWithTestCtx =
13
- <R1 = never, E1 = never>(ctxParams: WithTestCtxParams<R1, E1>) =>
14
- (testContext: Vitest.TestContext) =>
23
+ export const makeWithTestCtx: <R1, E1>(
24
+ ctxParams: WithTestCtxParams<R1, E1>,
25
+ ) => (
26
+ testContext: Vitest.TestContext,
27
+ ) => <A, E>(
28
+ self: Effect.Effect<A, E, Scope.Scope | NoInfer<R1> | OtelTracer.OtelTracer>,
29
+ ) => Effect.Effect<A, E1 | Cause.TimeoutException | E, Scope.Scope> =
30
+ (ctxParams) => (testContext: Vitest.TestContext) =>
15
31
  withTestCtx(testContext, ctxParams)
16
32
 
17
- export type WithTestCtxParams<R1 = never, E1 = never> = {
33
+ export type WithTestCtxParams<R1, E1> = {
18
34
  suffix?: string
19
35
  makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<R1, E1, Scope.Scope>
20
36
  timeout?: Duration.DurationInput
@@ -43,7 +59,11 @@ export const withTestCtx =
43
59
  const layer = makeLayer?.(testContext)
44
60
 
45
61
  const otelLayer =
46
- DEBUGGER_ACTIVE || forceOtel ? OtelLiveHttp({ serviceName: 'vitest-runner', skipLogUrl: false }) : OtelLiveDummy
62
+ DEBUGGER_ACTIVE || forceOtel
63
+ ? OtelLiveHttp({ rootSpanName: spanName, serviceName: 'vitest-runner', skipLogUrl: false })
64
+ : OtelLiveDummy
65
+
66
+ const combinedLayer = (layer ?? Layer.empty).pipe(Layer.provideMerge(otelLayer))
47
67
 
48
68
  return self.pipe(
49
69
  DEBUGGER_ACTIVE
@@ -53,10 +73,154 @@ export const withTestCtx =
53
73
  label: `${spanName} approaching timeout (timeout: ${Duration.format(timeout)})`,
54
74
  }),
55
75
  DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout),
56
- Effect.provide(otelLayer),
57
- Effect.provide(layer ?? Layer.empty),
76
+ Effect.provide(combinedLayer),
58
77
  Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
59
- Effect.withSpan(spanName),
60
78
  Effect.annotateLogs({ suffix }),
61
79
  ) as any
62
80
  }
81
+
82
+ /**
83
+ * Shared properties for all enhanced test context phases
84
+ */
85
+ export interface EnhancedTestContextBase {
86
+ numRuns: number
87
+ /** 0-based index */
88
+ runIndex: number
89
+ /** Total number of executions including initial runs and shrinking attempts */
90
+ totalExecutions: number
91
+ }
92
+
93
+ /**
94
+ * Enhanced context for property-based tests that includes shrinking phase information
95
+ */
96
+ export type EnhancedTestContext =
97
+ | (EnhancedTestContextBase & {
98
+ _tag: 'initial'
99
+ })
100
+ | (EnhancedTestContextBase & {
101
+ _tag: 'shrinking'
102
+ /** Number of shrinking attempts */
103
+ shrinkAttempt: number
104
+ })
105
+
106
+ /**
107
+ * Normalizes propOptions to ensure @effect/vitest receives correct fastCheck structure
108
+ */
109
+ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
110
+ propOptions:
111
+ | number
112
+ | (Vitest.TestOptions & {
113
+ fastCheck?: FC.Parameters<{
114
+ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
115
+ }>
116
+ }),
117
+ ): Vitest.TestOptions & {
118
+ fastCheck?: FC.Parameters<{
119
+ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
120
+ }>
121
+ } => {
122
+ // If it's a number, treat as timeout and add our default fastCheck
123
+ if (!Predicate.isObject(propOptions)) {
124
+ return {
125
+ timeout: propOptions,
126
+ fastCheck: { numRuns: 100 },
127
+ }
128
+ }
129
+
130
+ // If no fastCheck property, add it with our default numRuns
131
+ if (!propOptions.fastCheck) {
132
+ return {
133
+ ...propOptions,
134
+ fastCheck: { numRuns: 100 },
135
+ }
136
+ }
137
+
138
+ // If fastCheck exists but no numRuns, add our default
139
+ if (propOptions.fastCheck && !propOptions.fastCheck.numRuns) {
140
+ return {
141
+ ...propOptions,
142
+ fastCheck: {
143
+ ...propOptions.fastCheck,
144
+ numRuns: 100,
145
+ },
146
+ }
147
+ }
148
+
149
+ // If everything is properly structured, pass through
150
+ return propOptions
151
+ }
152
+
153
+ /**
154
+ * Equivalent to Vitest.prop but provides enhanced context including shrinking progress visibility
155
+ *
156
+ * This function enhances the standard property-based testing by providing clear information about
157
+ * whether FastCheck is in the initial testing phase or the shrinking phase, solving the confusion
158
+ * where tests show "Run 26/6" when FastCheck's shrinking algorithm is active.
159
+ *
160
+ * TODO: allow for upper timelimit instead of / additional to `numRuns`
161
+ *
162
+ * TODO: Upstream to Effect
163
+ */
164
+ export const asProp = <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(
165
+ api: Vitest.Vitest.Tester<R>,
166
+ name: string,
167
+ arbitraries: Arbs,
168
+ test: Vitest.Vitest.TestFunction<
169
+ A,
170
+ E,
171
+ R,
172
+ [
173
+ { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> },
174
+ Vitest.TestContext,
175
+ EnhancedTestContext,
176
+ ]
177
+ >,
178
+ propOptions:
179
+ | number
180
+ | (Vitest.TestOptions & {
181
+ fastCheck?: FC.Parameters<{
182
+ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
183
+ }>
184
+ }),
185
+ ) => {
186
+ const normalizedPropOptions = normalizePropOptions(propOptions)
187
+ const numRuns = normalizedPropOptions.fastCheck?.numRuns ?? 100
188
+ let runIndex = 0
189
+ let shrinkAttempts = 0
190
+ let totalExecutions = 0
191
+
192
+ return api.prop(
193
+ name,
194
+ arbitraries,
195
+ (properties, ctx) => {
196
+ if (ctx.signal.aborted) {
197
+ return ctx.skip('Test aborted')
198
+ }
199
+
200
+ totalExecutions++
201
+ const isInShrinkingPhase = runIndex >= numRuns
202
+
203
+ if (isInShrinkingPhase) {
204
+ shrinkAttempts++
205
+ }
206
+
207
+ const enhancedContext: EnhancedTestContext = isInShrinkingPhase
208
+ ? {
209
+ _tag: 'shrinking',
210
+ numRuns,
211
+ runIndex: runIndex++,
212
+ shrinkAttempt: shrinkAttempts,
213
+ totalExecutions,
214
+ }
215
+ : {
216
+ _tag: 'initial',
217
+ numRuns,
218
+ runIndex: runIndex++,
219
+ totalExecutions,
220
+ }
221
+
222
+ return test(properties, ctx, enhancedContext)
223
+ },
224
+ normalizedPropOptions,
225
+ )
226
+ }