@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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as inspector from 'node:inspector'
|
|
2
|
+
|
|
2
3
|
import type * as Vitest from '@effect/vitest'
|
|
4
|
+
|
|
3
5
|
import { IS_CI } from '@livestore/utils'
|
|
4
6
|
import {
|
|
5
7
|
type Cause,
|
|
@@ -14,30 +16,34 @@ import {
|
|
|
14
16
|
type Scope,
|
|
15
17
|
} from '@livestore/utils/effect'
|
|
16
18
|
import { OtelLiveDummy } from '@livestore/utils/node'
|
|
19
|
+
|
|
17
20
|
import { OtelLiveHttp } from '../node/mod.ts'
|
|
18
21
|
|
|
19
22
|
export * from '@effect/vitest'
|
|
20
23
|
|
|
21
24
|
export const DEBUGGER_ACTIVE = Boolean(process.env.DEBUGGER_ACTIVE ?? inspector.url() !== undefined)
|
|
22
25
|
|
|
26
|
+
type WithoutTestCtxServices<R> = Exclude<Exclude<R, OtelTracer.OtelTracer>, Scope.Scope>
|
|
27
|
+
type WithoutLayerAndTestCtxServices<R, ROut> = Exclude<Exclude<R, ROut | OtelTracer.OtelTracer>, Scope.Scope>
|
|
28
|
+
|
|
23
29
|
export const makeWithTestCtx: <ROut = never, E1 = never, RIn = never>(
|
|
24
30
|
ctxParams: WithTestCtxParams<ROut, E1, RIn>,
|
|
25
31
|
) => (testContext: Vitest.TestContext) => <A, E, R>(
|
|
26
32
|
self: Effect.Effect<A, E, R>,
|
|
27
33
|
) => Effect.Effect<
|
|
28
34
|
A,
|
|
29
|
-
E | E1 | Cause.
|
|
35
|
+
E | E1 | Cause.TimeoutError,
|
|
30
36
|
// Exclude dependencies provided by `withTestCtx` from the layer dependencies
|
|
31
|
-
|
|
|
37
|
+
| WithoutTestCtxServices<RIn>
|
|
32
38
|
// Exclude dependencies provided by `withTestCtx` **and** dependencies produced
|
|
33
39
|
// by the layer from the effect dependencies
|
|
34
|
-
|
|
|
40
|
+
| WithoutLayerAndTestCtxServices<R, ROut>
|
|
35
41
|
> = (ctxParams) => (testContext: Vitest.TestContext) => withTestCtx(testContext, ctxParams)
|
|
36
42
|
|
|
37
43
|
export type WithTestCtxParams<ROut, E1, RIn> = {
|
|
38
44
|
suffix?: string
|
|
39
45
|
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn | Scope.Scope>
|
|
40
|
-
timeout?: Duration.
|
|
46
|
+
timeout?: Duration.Input
|
|
41
47
|
forceOtel?: boolean
|
|
42
48
|
}
|
|
43
49
|
|
|
@@ -47,12 +53,12 @@ export const withTestCtx =
|
|
|
47
53
|
{
|
|
48
54
|
suffix,
|
|
49
55
|
makeLayer,
|
|
50
|
-
timeout = IS_CI ? 60_000 : 10_000,
|
|
56
|
+
timeout = IS_CI === true ? 60_000 : 10_000,
|
|
51
57
|
forceOtel = false,
|
|
52
58
|
}: {
|
|
53
59
|
suffix?: string
|
|
54
|
-
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn>
|
|
55
|
-
timeout?: Duration.
|
|
60
|
+
makeLayer?: (testContext: Vitest.TestContext) => Layer.Layer<ROut, E1, RIn | Scope.Scope>
|
|
61
|
+
timeout?: Duration.Input
|
|
56
62
|
forceOtel?: boolean
|
|
57
63
|
} = {},
|
|
58
64
|
) =>
|
|
@@ -60,35 +66,39 @@ export const withTestCtx =
|
|
|
60
66
|
self: Effect.Effect<A, E, R>,
|
|
61
67
|
): Effect.Effect<
|
|
62
68
|
A,
|
|
63
|
-
E | E1 | Cause.
|
|
69
|
+
E | E1 | Cause.TimeoutError,
|
|
64
70
|
// Exclude dependencies provided internally from the provided layer's dependencies
|
|
65
|
-
|
|
|
71
|
+
| WithoutTestCtxServices<RIn>
|
|
66
72
|
// Exclude dependencies provided internally **and** dependencies produced by the
|
|
67
73
|
// provided layer from the effect dependencies
|
|
68
|
-
|
|
|
74
|
+
| WithoutLayerAndTestCtxServices<R, ROut>
|
|
69
75
|
> => {
|
|
70
|
-
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix ? `:${suffix}` : ''}`
|
|
71
|
-
|
|
76
|
+
const spanName = `${testContext.task.suite?.name}:${testContext.task.name}${suffix !== undefined ? `:${suffix}` : ''}`
|
|
77
|
+
// `Layer.empty` provides `never`, which is narrower than an arbitrary generic
|
|
78
|
+
// `ROut`; widen it for the no-layer branch so `Effect.provide` can typecheck.
|
|
79
|
+
const layer: Layer.Layer<ROut, E1, RIn | Scope.Scope> =
|
|
80
|
+
makeLayer?.(testContext) ?? (Layer.empty as unknown as Layer.Layer<ROut, E1, RIn | Scope.Scope>)
|
|
81
|
+
const timeoutDuration = Duration.fromInputUnsafe(timeout)
|
|
72
82
|
|
|
73
83
|
const otelLayer =
|
|
74
|
-
DEBUGGER_ACTIVE || forceOtel
|
|
84
|
+
DEBUGGER_ACTIVE === true || forceOtel === true
|
|
75
85
|
? OtelLiveHttp({ rootSpanName: spanName, serviceName: 'vitest-runner', skipLogUrl: false })
|
|
76
86
|
: OtelLiveDummy
|
|
77
87
|
|
|
78
88
|
const combinedLayer = layer.pipe(Layer.provideMerge(otelLayer))
|
|
79
89
|
|
|
80
90
|
return self.pipe(
|
|
81
|
-
DEBUGGER_ACTIVE
|
|
91
|
+
DEBUGGER_ACTIVE === true
|
|
82
92
|
? identity
|
|
83
93
|
: Effect.logWarnIfTakesLongerThan({
|
|
84
|
-
duration: Duration.toMillis(
|
|
85
|
-
label: `${spanName} approaching timeout (timeout: ${Duration.format(
|
|
94
|
+
duration: Duration.toMillis(timeoutDuration) * 0.8,
|
|
95
|
+
label: `${spanName} approaching timeout (timeout: ${Duration.format(timeoutDuration)})`,
|
|
86
96
|
}),
|
|
87
|
-
DEBUGGER_ACTIVE ? identity : Effect.timeout(timeout),
|
|
97
|
+
DEBUGGER_ACTIVE === true ? identity : Effect.timeout(timeout),
|
|
88
98
|
Effect.provide(combinedLayer),
|
|
89
99
|
Effect.scoped, // We need to scope the effect manually here because otherwise the span is not closed
|
|
90
100
|
Effect.annotateLogs({ suffix }),
|
|
91
|
-
)
|
|
101
|
+
)
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
/**
|
|
@@ -118,21 +128,19 @@ export type EnhancedTestContext =
|
|
|
118
128
|
/**
|
|
119
129
|
* Normalizes propOptions to ensure @effect/vitest receives correct fastCheck structure
|
|
120
130
|
*/
|
|
131
|
+
type ArbitraryValues<Arbs extends Vitest.Vitest.Arbitraries> = {
|
|
132
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T : never
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type PropOptions<Arbs extends Vitest.Vitest.Arbitraries> = Omit<Vitest.TestOptions, 'fastCheck'> & {
|
|
136
|
+
fastCheck?: FC.Parameters<ArbitraryValues<Arbs>>
|
|
137
|
+
}
|
|
138
|
+
|
|
121
139
|
const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
122
|
-
propOptions:
|
|
123
|
-
|
|
124
|
-
| (Vitest.TestOptions & {
|
|
125
|
-
fastCheck?: FC.Parameters<{
|
|
126
|
-
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
|
|
127
|
-
}>
|
|
128
|
-
}),
|
|
129
|
-
): Vitest.TestOptions & {
|
|
130
|
-
fastCheck?: FC.Parameters<{
|
|
131
|
-
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
|
|
132
|
-
}>
|
|
133
|
-
} => {
|
|
140
|
+
propOptions: number | PropOptions<Arbs>,
|
|
141
|
+
): PropOptions<Arbs> => {
|
|
134
142
|
// If it's a number, treat as timeout and add our default fastCheck
|
|
135
|
-
if (
|
|
143
|
+
if (Predicate.isObject(propOptions) === false) {
|
|
136
144
|
return {
|
|
137
145
|
timeout: propOptions,
|
|
138
146
|
fastCheck: { numRuns: 100 },
|
|
@@ -140,7 +148,7 @@ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
// If no fastCheck property, add it with our default numRuns
|
|
143
|
-
if (
|
|
151
|
+
if (propOptions.fastCheck == null) {
|
|
144
152
|
return {
|
|
145
153
|
...propOptions,
|
|
146
154
|
fastCheck: { numRuns: 100 },
|
|
@@ -148,7 +156,7 @@ const normalizePropOptions = <Arbs extends Vitest.Vitest.Arbitraries>(
|
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
// If fastCheck exists but no numRuns, add our default
|
|
151
|
-
if (propOptions.fastCheck &&
|
|
159
|
+
if (propOptions.fastCheck !== undefined && propOptions.fastCheck.numRuns == null) {
|
|
152
160
|
return {
|
|
153
161
|
...propOptions,
|
|
154
162
|
fastCheck: {
|
|
@@ -177,23 +185,8 @@ export const asProp = <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(
|
|
|
177
185
|
api: Vitest.Vitest.Tester<R>,
|
|
178
186
|
name: string,
|
|
179
187
|
arbitraries: Arbs,
|
|
180
|
-
test: Vitest.Vitest.TestFunction<
|
|
181
|
-
|
|
182
|
-
E,
|
|
183
|
-
R,
|
|
184
|
-
[
|
|
185
|
-
{ [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> },
|
|
186
|
-
Vitest.TestContext,
|
|
187
|
-
EnhancedTestContext,
|
|
188
|
-
]
|
|
189
|
-
>,
|
|
190
|
-
propOptions:
|
|
191
|
-
| number
|
|
192
|
-
| (Vitest.TestOptions & {
|
|
193
|
-
fastCheck?: FC.Parameters<{
|
|
194
|
-
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]>
|
|
195
|
-
}>
|
|
196
|
-
}),
|
|
188
|
+
test: Vitest.Vitest.TestFunction<A, E, R, [ArbitraryValues<Arbs>, Vitest.TestContext, EnhancedTestContext]>,
|
|
189
|
+
propOptions: number | PropOptions<Arbs>,
|
|
197
190
|
) => {
|
|
198
191
|
const normalizedPropOptions = normalizePropOptions(propOptions)
|
|
199
192
|
const numRuns = normalizedPropOptions.fastCheck?.numRuns ?? 100
|
|
@@ -205,31 +198,32 @@ export const asProp = <Arbs extends Vitest.Vitest.Arbitraries, A, E, R>(
|
|
|
205
198
|
name,
|
|
206
199
|
arbitraries,
|
|
207
200
|
(properties, ctx) => {
|
|
208
|
-
if (ctx.signal.aborted) {
|
|
201
|
+
if (ctx.signal.aborted === true) {
|
|
209
202
|
return ctx.skip('Test aborted')
|
|
210
203
|
}
|
|
211
204
|
|
|
212
205
|
totalExecutions++
|
|
213
206
|
const isInShrinkingPhase = runIndex >= numRuns
|
|
214
207
|
|
|
215
|
-
if (isInShrinkingPhase) {
|
|
208
|
+
if (isInShrinkingPhase === true) {
|
|
216
209
|
shrinkAttempts++
|
|
217
210
|
}
|
|
218
211
|
|
|
219
|
-
const enhancedContext: EnhancedTestContext =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
212
|
+
const enhancedContext: EnhancedTestContext =
|
|
213
|
+
isInShrinkingPhase === true
|
|
214
|
+
? {
|
|
215
|
+
_tag: 'shrinking',
|
|
216
|
+
numRuns,
|
|
217
|
+
runIndex: runIndex++,
|
|
218
|
+
shrinkAttempt: shrinkAttempts,
|
|
219
|
+
totalExecutions,
|
|
220
|
+
}
|
|
221
|
+
: {
|
|
222
|
+
_tag: 'initial',
|
|
223
|
+
numRuns,
|
|
224
|
+
runIndex: runIndex++,
|
|
225
|
+
totalExecutions,
|
|
226
|
+
}
|
|
233
227
|
|
|
234
228
|
return test(properties, ctx, enhancedContext)
|
|
235
229
|
},
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
import { Effect, FetchHttpClient, Layer } from '@livestore/utils/effect'
|
|
2
|
-
import { getFreePort, PlatformNode } from '@livestore/utils/node'
|
|
3
|
-
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
4
1
|
import { expect } from 'vitest'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
4
|
+
import { Effect, FetchHttpClient, Layer, Result } from '@livestore/utils/effect'
|
|
5
|
+
import { getFreePort, PlatformNode } from '@livestore/utils/node'
|
|
6
|
+
|
|
7
|
+
import * as WranglerDevServer from './WranglerDevServer.ts'
|
|
10
8
|
|
|
11
9
|
const testTimeout = 60_000
|
|
12
10
|
|
|
13
|
-
const WranglerDevServerTest = (args: Partial<
|
|
14
|
-
|
|
11
|
+
const WranglerDevServerTest = (args: Partial<WranglerDevServer.Options> = {}) =>
|
|
12
|
+
WranglerDevServer.layer({
|
|
15
13
|
cwd: `${import.meta.dirname}/fixtures`,
|
|
16
14
|
...args,
|
|
17
15
|
}).pipe(Layer.provide(FetchHttpClient.layer))
|
|
18
16
|
|
|
19
17
|
Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
|
|
20
18
|
Vitest.describe('Basic Operations', () => {
|
|
21
|
-
const withBasicTest = (args: Partial<
|
|
19
|
+
const withBasicTest = (args: Partial<WranglerDevServer.Options> = {}) =>
|
|
22
20
|
Vitest.makeWithTestCtx({
|
|
23
21
|
timeout: testTimeout,
|
|
24
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
22
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
25
23
|
})
|
|
26
24
|
|
|
27
|
-
Vitest.
|
|
25
|
+
Vitest.live('should start wrangler dev server and return port', (test) =>
|
|
28
26
|
Effect.gen(function* () {
|
|
29
|
-
const server = yield*
|
|
27
|
+
const server = yield* WranglerDevServer.WranglerDevServer
|
|
30
28
|
|
|
31
29
|
expect(server.port).toBeGreaterThan(0)
|
|
32
30
|
expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/)
|
|
33
31
|
}).pipe(withBasicTest()(test)),
|
|
34
32
|
)
|
|
35
33
|
|
|
36
|
-
Vitest.
|
|
34
|
+
Vitest.live('should use specified port when provided', (test) =>
|
|
37
35
|
Effect.andThen(getFreePort, (port) =>
|
|
38
36
|
Effect.gen(function* () {
|
|
39
|
-
const server = yield*
|
|
37
|
+
const server = yield* WranglerDevServer.WranglerDevServer
|
|
40
38
|
|
|
41
39
|
expect(server.port).toBe(port)
|
|
42
40
|
expect(server.url).toBe(`http://127.0.0.1:${port}`)
|
|
@@ -46,83 +44,83 @@ Vitest.describe('WranglerDevServer', { timeout: testTimeout }, () => {
|
|
|
46
44
|
})
|
|
47
45
|
|
|
48
46
|
Vitest.describe('Error Handling', () => {
|
|
49
|
-
const withErrorTest = (args: Partial<
|
|
47
|
+
const withErrorTest = (args: Partial<WranglerDevServer.Options> = {}) =>
|
|
50
48
|
Vitest.makeWithTestCtx({
|
|
51
49
|
timeout: testTimeout,
|
|
52
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
50
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
53
51
|
})
|
|
54
52
|
|
|
55
|
-
Vitest.
|
|
53
|
+
Vitest.live('should handle missing wrangler.toml but should timeout', (test) =>
|
|
56
54
|
Effect.gen(function* () {
|
|
57
|
-
const error = yield*
|
|
55
|
+
const error = yield* WranglerDevServer.WranglerDevServer.pipe(
|
|
58
56
|
Effect.provide(
|
|
59
57
|
WranglerDevServerTest({
|
|
60
58
|
cwd: '/tmp',
|
|
61
59
|
wranglerConfigPath: '/dev/null',
|
|
62
|
-
connectTimeout: '500 millis',
|
|
63
|
-
}).pipe(Layer.provide(PlatformNode.
|
|
60
|
+
readiness: { connectTimeout: '500 millis' },
|
|
61
|
+
}).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
64
62
|
),
|
|
65
63
|
Effect.flip,
|
|
66
64
|
)
|
|
67
65
|
|
|
68
|
-
expect(error).toBeInstanceOf(WranglerDevServerError)
|
|
66
|
+
expect(error).toBeInstanceOf(WranglerDevServer.WranglerDevServerError)
|
|
69
67
|
}).pipe(Vitest.withTestCtx(test)),
|
|
70
68
|
)
|
|
71
69
|
|
|
72
|
-
Vitest.
|
|
70
|
+
Vitest.live('should handle invalid working directory', (test) =>
|
|
73
71
|
Effect.gen(function* () {
|
|
74
|
-
const result = yield*
|
|
72
|
+
const result = yield* WranglerDevServer.WranglerDevServer.pipe(
|
|
75
73
|
Effect.provide(
|
|
76
74
|
WranglerDevServerTest({
|
|
77
75
|
cwd: '/completely/nonexistent/directory',
|
|
78
|
-
}).pipe(Layer.provide(PlatformNode.
|
|
76
|
+
}).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
79
77
|
),
|
|
80
|
-
Effect.
|
|
78
|
+
Effect.result,
|
|
81
79
|
)
|
|
82
80
|
|
|
83
|
-
expect(result._tag).toBe('
|
|
84
|
-
if (result._tag === '
|
|
85
|
-
expect(result.
|
|
81
|
+
expect(result._tag).toBe('Failure')
|
|
82
|
+
if (result._tag === 'Failure') {
|
|
83
|
+
expect(result.failure).toBeInstanceOf(WranglerDevServer.WranglerDevServerError)
|
|
86
84
|
}
|
|
87
85
|
}).pipe(Vitest.withTestCtx(test)),
|
|
88
86
|
)
|
|
89
87
|
|
|
90
|
-
Vitest.
|
|
88
|
+
Vitest.live('should timeout if server fails to start', (test) =>
|
|
91
89
|
Effect.gen(function* () {
|
|
92
90
|
// Create a command that will never output "Ready on"
|
|
93
|
-
const result = yield*
|
|
91
|
+
const result = yield* WranglerDevServer.WranglerDevServer.pipe(
|
|
94
92
|
// Override the timeout for this test to be shorter
|
|
95
93
|
Effect.timeout('5 seconds'),
|
|
96
|
-
Effect.
|
|
94
|
+
Effect.result,
|
|
97
95
|
)
|
|
98
96
|
|
|
99
97
|
// This might succeed or fail depending on actual wrangler behavior
|
|
100
98
|
// The main point is testing timeout functionality
|
|
101
|
-
expect(['
|
|
99
|
+
expect(['Failure', 'Success']).toContain(result._tag)
|
|
102
100
|
}).pipe(withErrorTest()(test)),
|
|
103
101
|
)
|
|
104
102
|
})
|
|
105
103
|
|
|
106
104
|
Vitest.describe('Service Pattern', () => {
|
|
107
|
-
const withServiceTest = (args: Partial<
|
|
105
|
+
const withServiceTest = (args: Partial<WranglerDevServer.Options> = {}) =>
|
|
108
106
|
Vitest.makeWithTestCtx({
|
|
109
107
|
timeout: testTimeout,
|
|
110
|
-
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.
|
|
108
|
+
makeLayer: () => WranglerDevServerTest(args).pipe(Layer.provide(PlatformNode.NodeServices.layer)),
|
|
111
109
|
})
|
|
112
110
|
|
|
113
|
-
Vitest.
|
|
111
|
+
Vitest.live('should work with service pattern', (test) =>
|
|
114
112
|
Effect.gen(function* () {
|
|
115
|
-
const server = yield*
|
|
113
|
+
const server = yield* WranglerDevServer.WranglerDevServer
|
|
116
114
|
|
|
117
115
|
expect(server.port).toBeGreaterThan(0)
|
|
118
116
|
expect(server.url).toMatch(/http:\/\/127.0.0.1:\d+/)
|
|
119
117
|
}).pipe(withServiceTest()(test)),
|
|
120
118
|
)
|
|
121
119
|
|
|
122
|
-
Vitest.
|
|
120
|
+
Vitest.live('should work with custom port via service', (test) =>
|
|
123
121
|
Effect.andThen(getFreePort, (port) =>
|
|
124
122
|
Effect.gen(function* () {
|
|
125
|
-
const server = yield*
|
|
123
|
+
const server = yield* WranglerDevServer.WranglerDevServer
|
|
126
124
|
|
|
127
125
|
expect(server.port).toBe(port)
|
|
128
126
|
expect(server.url).toBe(`http://127.0.0.1:${port}`)
|