@effect/vitest 0.26.0 → 4.0.0-beta.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/README.md +35 -51
- package/dist/{dts/index.d.ts → index.d.ts} +29 -65
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +8 -23
- package/dist/index.js.map +1 -0
- package/dist/internal/internal.d.ts +5 -0
- package/dist/internal/internal.d.ts.map +1 -0
- package/dist/{esm/internal → internal}/internal.js +60 -70
- package/dist/internal/internal.js.map +1 -0
- package/dist/{dts/utils.d.ts → utils.d.ts} +41 -29
- package/dist/utils.d.ts.map +1 -0
- package/dist/{esm/utils.js → utils.js} +54 -35
- package/dist/utils.js.map +1 -0
- package/package.json +37 -36
- package/src/index.ts +45 -88
- package/src/internal/internal.ts +87 -108
- package/src/utils.ts +70 -43
- package/dist/cjs/index.js +0 -137
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internal/internal.js +0 -194
- package/dist/cjs/internal/internal.js.map +0 -1
- package/dist/cjs/utils.js +0 -232
- package/dist/cjs/utils.js.map +0 -1
- package/dist/dts/index.d.ts.map +0 -1
- package/dist/dts/internal/internal.d.ts +0 -2
- package/dist/dts/internal/internal.d.ts.map +0 -1
- package/dist/dts/utils.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internal/internal.js.map +0 -1
- package/dist/esm/package.json +0 -4
- package/dist/esm/utils.js.map +0 -1
- package/index/package.json +0 -6
- package/utils/package.json +0 -6
package/package.json
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/vitest",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"description": "A set of helpers for testing Effects with vitest",
|
|
7
|
+
"homepage": "https://effect.website",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/Effect-TS/effect.git",
|
|
10
|
+
"url": "https://github.com/Effect-TS/effect-smol.git",
|
|
9
11
|
"directory": "packages/vitest"
|
|
10
12
|
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Effect-TS/effect-smol/issues"
|
|
15
|
+
},
|
|
11
16
|
"sideEffects": [],
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
".": "./dist/index.js",
|
|
20
|
+
"./*": "./dist/*.js",
|
|
21
|
+
"./internal/*": null,
|
|
22
|
+
"./*/index": null
|
|
16
23
|
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src/**/*.ts",
|
|
26
|
+
"dist/**/*.js",
|
|
27
|
+
"dist/**/*.js.map",
|
|
28
|
+
"dist/**/*.d.ts",
|
|
29
|
+
"dist/**/*.d.ts.map"
|
|
30
|
+
],
|
|
17
31
|
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
18
33
|
"provenance": true
|
|
19
34
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"default": "./dist/cjs/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./index": {
|
|
31
|
-
"types": "./dist/dts/index.d.ts",
|
|
32
|
-
"import": "./dist/esm/index.js",
|
|
33
|
-
"default": "./dist/cjs/index.js"
|
|
34
|
-
},
|
|
35
|
-
"./utils": {
|
|
36
|
-
"types": "./dist/dts/utils.d.ts",
|
|
37
|
-
"import": "./dist/esm/utils.js",
|
|
38
|
-
"default": "./dist/cjs/utils.js"
|
|
39
|
-
}
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"vitest": "^3.0.0",
|
|
37
|
+
"effect": "^4.0.0-beta.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^25.2.0",
|
|
41
|
+
"vitest": "4.0.18",
|
|
42
|
+
"effect": "^4.0.0-beta.0"
|
|
40
43
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
]
|
|
49
|
-
}
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -b tsconfig.json && pnpm babel",
|
|
46
|
+
"build:tsgo": "tsgo -b tsconfig.json && pnpm babel",
|
|
47
|
+
"babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
|
|
48
|
+
"check": "tsc -b tsconfig.json",
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"coverage": "vitest --coverage"
|
|
50
51
|
}
|
|
51
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as Duration from "effect/Duration"
|
|
5
5
|
import type * as Effect from "effect/Effect"
|
|
6
|
-
import type * as FC from "effect/FastCheck"
|
|
7
6
|
import type * as Layer from "effect/Layer"
|
|
8
7
|
import type * as Schema from "effect/Schema"
|
|
9
8
|
import type * as Scope from "effect/Scope"
|
|
10
|
-
import type * as
|
|
9
|
+
import type * as FC from "effect/testing/FastCheck"
|
|
11
10
|
import * as V from "vitest"
|
|
12
|
-
import * as internal from "./internal/internal.
|
|
11
|
+
import * as internal from "./internal/internal.ts"
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* @since 1.0.0
|
|
@@ -19,43 +18,7 @@ export * from "vitest"
|
|
|
19
18
|
/**
|
|
20
19
|
* @since 1.0.0
|
|
21
20
|
*/
|
|
22
|
-
export type API =
|
|
23
|
-
& { scopedFixtures: V.TestAPI<{}>["scoped"] }
|
|
24
|
-
& { [K in keyof V.TestAPI<{}>]: K extends "scoped" ? unknown : V.TestAPI<{}>[K] }
|
|
25
|
-
& TestCollectorCallable
|
|
26
|
-
|
|
27
|
-
interface TestCollectorCallable<C = object> {
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Use options as the second argument instead
|
|
30
|
-
*/
|
|
31
|
-
<ExtraContext extends C>(
|
|
32
|
-
name: string | Function,
|
|
33
|
-
fn: V.TestFunction<ExtraContext>,
|
|
34
|
-
options: TestCollectorOptions
|
|
35
|
-
): void
|
|
36
|
-
<ExtraContext extends C>(
|
|
37
|
-
name: string | Function,
|
|
38
|
-
fn?: V.TestFunction<ExtraContext>,
|
|
39
|
-
options?: number | TestCollectorOptions
|
|
40
|
-
): void
|
|
41
|
-
<ExtraContext extends C>(
|
|
42
|
-
name: string | Function,
|
|
43
|
-
options?: TestCollectorOptions,
|
|
44
|
-
fn?: V.TestFunction<ExtraContext>
|
|
45
|
-
): void
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type TestCollectorOptions = {
|
|
49
|
-
concurrent?: boolean
|
|
50
|
-
sequential?: boolean
|
|
51
|
-
only?: boolean
|
|
52
|
-
skip?: boolean
|
|
53
|
-
todo?: boolean
|
|
54
|
-
fails?: boolean
|
|
55
|
-
timeout?: number
|
|
56
|
-
retry?: number
|
|
57
|
-
repeats?: number
|
|
58
|
-
}
|
|
21
|
+
export type API = V.TestAPI<{}>
|
|
59
22
|
|
|
60
23
|
/**
|
|
61
24
|
* @since 1.0.0
|
|
@@ -83,8 +46,8 @@ export namespace Vitest {
|
|
|
83
46
|
* @since 1.0.0
|
|
84
47
|
*/
|
|
85
48
|
export type Arbitraries =
|
|
86
|
-
| Array<Schema.Schema
|
|
87
|
-
| { [K in string]: Schema.Schema
|
|
49
|
+
| Array<Schema.Schema<any> | FC.Arbitrary<any>>
|
|
50
|
+
| { [K in string]: Schema.Schema<any> | FC.Arbitrary<any> }
|
|
88
51
|
|
|
89
52
|
/**
|
|
90
53
|
* @since 1.0.0
|
|
@@ -110,7 +73,11 @@ export namespace Vitest {
|
|
|
110
73
|
E,
|
|
111
74
|
R,
|
|
112
75
|
[
|
|
113
|
-
{
|
|
76
|
+
{
|
|
77
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T
|
|
78
|
+
: Arbs[K] extends Schema.Schema<infer T> ? T
|
|
79
|
+
: never
|
|
80
|
+
},
|
|
114
81
|
V.TestContext
|
|
115
82
|
]
|
|
116
83
|
>,
|
|
@@ -118,7 +85,10 @@ export namespace Vitest {
|
|
|
118
85
|
| number
|
|
119
86
|
| V.TestOptions & {
|
|
120
87
|
fastCheck?: FC.Parameters<
|
|
121
|
-
{
|
|
88
|
+
{
|
|
89
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T
|
|
90
|
+
: never
|
|
91
|
+
}
|
|
122
92
|
>
|
|
123
93
|
}
|
|
124
94
|
) => void
|
|
@@ -127,22 +97,19 @@ export namespace Vitest {
|
|
|
127
97
|
/**
|
|
128
98
|
* @since 1.0.0
|
|
129
99
|
*/
|
|
130
|
-
export interface MethodsNonLive<R = never
|
|
131
|
-
readonly effect: Vitest.Tester<
|
|
100
|
+
export interface MethodsNonLive<R = never> extends API {
|
|
101
|
+
readonly effect: Vitest.Tester<R | Scope.Scope>
|
|
132
102
|
readonly flakyTest: <A, E, R2>(
|
|
133
|
-
self: Effect.Effect<A, E, R2>,
|
|
103
|
+
self: Effect.Effect<A, E, R2 | Scope.Scope>,
|
|
134
104
|
timeout?: Duration.DurationInput
|
|
135
105
|
) => Effect.Effect<A, never, R2>
|
|
136
|
-
readonly scoped: Vitest.Tester<
|
|
137
|
-
(ExcludeTestServices extends true ? never : TestServices.TestServices) | Scope.Scope | R
|
|
138
|
-
>
|
|
139
106
|
readonly layer: <R2, E>(layer: Layer.Layer<R2, E, R>, options?: {
|
|
140
107
|
readonly timeout?: Duration.DurationInput
|
|
141
108
|
}) => {
|
|
142
|
-
(f: (it: Vitest.MethodsNonLive<R | R2
|
|
109
|
+
(f: (it: Vitest.MethodsNonLive<R | R2>) => void): void
|
|
143
110
|
(
|
|
144
111
|
name: string,
|
|
145
|
-
f: (it: Vitest.MethodsNonLive<R | R2
|
|
112
|
+
f: (it: Vitest.MethodsNonLive<R | R2>) => void
|
|
146
113
|
): void
|
|
147
114
|
}
|
|
148
115
|
|
|
@@ -153,14 +120,20 @@ export namespace Vitest {
|
|
|
153
120
|
name: string,
|
|
154
121
|
arbitraries: Arbs,
|
|
155
122
|
self: (
|
|
156
|
-
properties: {
|
|
123
|
+
properties: {
|
|
124
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T
|
|
125
|
+
: never
|
|
126
|
+
},
|
|
157
127
|
ctx: V.TestContext
|
|
158
128
|
) => void,
|
|
159
129
|
timeout?:
|
|
160
130
|
| number
|
|
161
131
|
| V.TestOptions & {
|
|
162
132
|
fastCheck?: FC.Parameters<
|
|
163
|
-
{
|
|
133
|
+
{
|
|
134
|
+
[K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Arbs[K] extends Schema.Schema<infer T> ? T
|
|
135
|
+
: never
|
|
136
|
+
}
|
|
164
137
|
>
|
|
165
138
|
}
|
|
166
139
|
) => void
|
|
@@ -170,8 +143,7 @@ export namespace Vitest {
|
|
|
170
143
|
* @since 1.0.0
|
|
171
144
|
*/
|
|
172
145
|
export interface Methods<R = never> extends MethodsNonLive<R> {
|
|
173
|
-
readonly live: Vitest.Tester<R>
|
|
174
|
-
readonly scopedLive: Vitest.Tester<Scope.Scope | R>
|
|
146
|
+
readonly live: Vitest.Tester<Scope.Scope | R>
|
|
175
147
|
}
|
|
176
148
|
}
|
|
177
149
|
|
|
@@ -183,22 +155,12 @@ export const addEqualityTesters: () => void = internal.addEqualityTesters
|
|
|
183
155
|
/**
|
|
184
156
|
* @since 1.0.0
|
|
185
157
|
*/
|
|
186
|
-
export const effect: Vitest.Tester<
|
|
158
|
+
export const effect: Vitest.Tester<Scope.Scope> = internal.effect
|
|
187
159
|
|
|
188
160
|
/**
|
|
189
161
|
* @since 1.0.0
|
|
190
162
|
*/
|
|
191
|
-
export const
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* @since 1.0.0
|
|
195
|
-
*/
|
|
196
|
-
export const live: Vitest.Tester<never> = internal.live
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* @since 1.0.0
|
|
200
|
-
*/
|
|
201
|
-
export const scopedLive: Vitest.Tester<Scope.Scope> = internal.scopedLive
|
|
163
|
+
export const live: Vitest.Tester<Scope.Scope> = internal.live
|
|
202
164
|
|
|
203
165
|
/**
|
|
204
166
|
* Share a `Layer` between multiple tests, optionally wrapping
|
|
@@ -208,13 +170,13 @@ export const scopedLive: Vitest.Tester<Scope.Scope> = internal.scopedLive
|
|
|
208
170
|
*
|
|
209
171
|
* ```ts
|
|
210
172
|
* import { expect, layer } from "@effect/vitest"
|
|
211
|
-
* import {
|
|
173
|
+
* import { Effect, Layer, ServiceMap } from "effect"
|
|
212
174
|
*
|
|
213
|
-
* class Foo extends
|
|
175
|
+
* class Foo extends ServiceMap.Service("Foo")<Foo, "foo">() {
|
|
214
176
|
* static Live = Layer.succeed(Foo, "foo")
|
|
215
177
|
* }
|
|
216
178
|
*
|
|
217
|
-
* class Bar extends
|
|
179
|
+
* class Bar extends ServiceMap.Service("Bar")<Bar, "bar">() {
|
|
218
180
|
* static Live = Layer.effect(
|
|
219
181
|
* Bar,
|
|
220
182
|
* Effect.map(Foo, () => "bar" as const)
|
|
@@ -223,42 +185,40 @@ export const scopedLive: Vitest.Tester<Scope.Scope> = internal.scopedLive
|
|
|
223
185
|
*
|
|
224
186
|
* layer(Foo.Live)("layer", (it) => {
|
|
225
187
|
* it.effect("adds context", () =>
|
|
226
|
-
* Effect.gen(function*
|
|
188
|
+
* Effect.gen(function*() {
|
|
227
189
|
* const foo = yield* Foo
|
|
228
190
|
* expect(foo).toEqual("foo")
|
|
229
|
-
* })
|
|
230
|
-
* )
|
|
191
|
+
* }))
|
|
231
192
|
*
|
|
232
193
|
* it.layer(Bar.Live)("nested", (it) => {
|
|
233
194
|
* it.effect("adds context", () =>
|
|
234
|
-
* Effect.gen(function*
|
|
195
|
+
* Effect.gen(function*() {
|
|
235
196
|
* const foo = yield* Foo
|
|
236
197
|
* const bar = yield* Bar
|
|
237
198
|
* expect(foo).toEqual("foo")
|
|
238
199
|
* expect(bar).toEqual("bar")
|
|
239
|
-
* })
|
|
240
|
-
* )
|
|
200
|
+
* }))
|
|
241
201
|
* })
|
|
242
202
|
* })
|
|
243
203
|
* ```
|
|
244
204
|
*/
|
|
245
|
-
export const layer: <R, E
|
|
205
|
+
export const layer: <R, E>(
|
|
246
206
|
layer_: Layer.Layer<R, E>,
|
|
247
207
|
options?: {
|
|
248
208
|
readonly memoMap?: Layer.MemoMap
|
|
249
209
|
readonly timeout?: Duration.DurationInput
|
|
250
|
-
readonly excludeTestServices?:
|
|
210
|
+
readonly excludeTestServices?: boolean
|
|
251
211
|
}
|
|
252
212
|
) => {
|
|
253
|
-
(f: (it: Vitest.MethodsNonLive<R
|
|
254
|
-
(name: string, f: (it: Vitest.MethodsNonLive<R
|
|
213
|
+
(f: (it: Vitest.MethodsNonLive<R>) => void): void
|
|
214
|
+
(name: string, f: (it: Vitest.MethodsNonLive<R>) => void): void
|
|
255
215
|
} = internal.layer
|
|
256
216
|
|
|
257
217
|
/**
|
|
258
218
|
* @since 1.0.0
|
|
259
219
|
*/
|
|
260
220
|
export const flakyTest: <A, E, R>(
|
|
261
|
-
self: Effect.Effect<A, E, R>,
|
|
221
|
+
self: Effect.Effect<A, E, R | Scope.Scope>,
|
|
262
222
|
timeout?: Duration.DurationInput
|
|
263
223
|
) => Effect.Effect<A, never, R> = internal.flakyTest
|
|
264
224
|
|
|
@@ -272,20 +232,17 @@ export const prop: Vitest.Methods["prop"] = internal.prop
|
|
|
272
232
|
*/
|
|
273
233
|
|
|
274
234
|
/** @ignored */
|
|
275
|
-
const methods = { effect, live, flakyTest,
|
|
235
|
+
const methods = { effect, live, flakyTest, layer, prop } as const
|
|
276
236
|
|
|
277
237
|
/**
|
|
278
238
|
* @since 1.0.0
|
|
279
239
|
*/
|
|
280
|
-
export const it: Vitest.Methods = Object.assign(V.it,
|
|
281
|
-
...methods,
|
|
282
|
-
scopedFixtures: V.it.scoped.bind(V.it)
|
|
283
|
-
})
|
|
240
|
+
export const it: Vitest.Methods = Object.assign(V.it, methods)
|
|
284
241
|
|
|
285
242
|
/**
|
|
286
243
|
* @since 1.0.0
|
|
287
244
|
*/
|
|
288
|
-
export const makeMethods: (it:
|
|
245
|
+
export const makeMethods: (it: V.TestAPI) => Vitest.Methods = internal.makeMethods
|
|
289
246
|
|
|
290
247
|
/**
|
|
291
248
|
* @since 1.0.0
|