@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/package.json CHANGED
@@ -1,51 +1,52 @@
1
1
  {
2
2
  "name": "@effect/vitest",
3
- "version": "0.26.0",
4
- "description": "A set of helpers for testing Effects with vitest",
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
- "homepage": "https://effect.website",
13
- "peerDependencies": {
14
- "vitest": "^3.2.0",
15
- "effect": "^3.18.0"
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
- "main": "./dist/cjs/index.js",
21
- "module": "./dist/esm/index.js",
22
- "types": "./dist/dts/index.d.ts",
23
- "exports": {
24
- "./package.json": "./package.json",
25
- ".": {
26
- "types": "./dist/dts/index.d.ts",
27
- "import": "./dist/esm/index.js",
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
- "typesVersions": {
42
- "*": {
43
- "index": [
44
- "./dist/dts/index.d.ts"
45
- ],
46
- "utils": [
47
- "./dist/dts/utils.d.ts"
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 TestServices from "effect/TestServices"
9
+ import type * as FC from "effect/testing/FastCheck"
11
10
  import * as V from "vitest"
12
- import * as internal from "./internal/internal.js"
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.Any | FC.Arbitrary<any>>
87
- | { [K in string]: Schema.Schema.Any | FC.Arbitrary<any> }
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
- { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> },
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
- { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> }
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, ExcludeTestServices extends boolean = false> extends API {
131
- readonly effect: Vitest.Tester<(ExcludeTestServices extends true ? never : TestServices.TestServices) | R>
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, ExcludeTestServices>) => void): void
109
+ (f: (it: Vitest.MethodsNonLive<R | R2>) => void): void
143
110
  (
144
111
  name: string,
145
- f: (it: Vitest.MethodsNonLive<R | R2, ExcludeTestServices>) => void
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: { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> },
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
- { [K in keyof Arbs]: Arbs[K] extends FC.Arbitrary<infer T> ? T : Schema.Schema.Type<Arbs[K]> }
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<TestServices.TestServices> = internal.effect
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 scoped: Vitest.Tester<TestServices.TestServices | Scope.Scope> = internal.scoped
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 { Context, Effect, Layer } from "effect"
173
+ * import { Effect, Layer, ServiceMap } from "effect"
212
174
  *
213
- * class Foo extends Context.Tag("Foo")<Foo, "foo">() {
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 Context.Tag("Bar")<Bar, "bar">() {
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, const ExcludeTestServices extends boolean = false>(
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?: ExcludeTestServices
210
+ readonly excludeTestServices?: boolean
251
211
  }
252
212
  ) => {
253
- (f: (it: Vitest.MethodsNonLive<R, ExcludeTestServices>) => void): void
254
- (name: string, f: (it: Vitest.MethodsNonLive<R, ExcludeTestServices>) => void): void
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, scoped, scopedLive, layer, prop } as const
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: API) => Vitest.Methods = internal.makeMethods
245
+ export const makeMethods: (it: V.TestAPI) => Vitest.Methods = internal.makeMethods
289
246
 
290
247
  /**
291
248
  * @since 1.0.0