@systemfsoftware/vitest 0.0.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/CHANGELOG.md +17 -0
- package/LICENSE +203 -0
- package/README.md +236 -0
- package/dist/TestClock.d.ts +6 -0
- package/dist/TestClock.mjs +6 -0
- package/dist/compat.d.ts +11 -0
- package/dist/index.d.ts +735 -0
- package/dist/index.mjs +1523 -0
- package/dist/refusals-BQtDszyU.mjs +32 -0
- package/dist/refusals-_6e3GzVK.d.ts +37 -0
- package/dist/refusals.d.ts +3 -0
- package/dist/refusals.mjs +3 -0
- package/dist/utils.d.ts +197 -0
- package/dist/utils.mjs +227 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
/// <reference types="./compat.d.ts" />
|
|
2
|
+
import { n as NarrowVacuousName, r as PresenceRefusal, t as NarrowNegatedName } from "./refusals-_6e3GzVK.js";
|
|
3
|
+
import * as V from "vitest";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Cause from "effect/Cause";
|
|
8
|
+
import * as Duration from "effect/Duration";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as Scheduler from "effect/Scheduler";
|
|
11
|
+
import * as Schema$1 from "effect/Schema";
|
|
12
|
+
import * as Scope from "effect/Scope";
|
|
13
|
+
import * as TestClock from "effect/testing/TestClock";
|
|
14
|
+
import * as TestConsole from "effect/testing/TestConsole";
|
|
15
|
+
import * as Arbitrary from "effect/unstable/arbitrary/Arbitrary";
|
|
16
|
+
import * as Clock from "effect/Clock";
|
|
17
|
+
export * from "vitest";
|
|
18
|
+
declare namespace expect_d_exports {
|
|
19
|
+
export { Lawful, LawfulCheck, LawfulExpectStatic, LawfulNot, afterAll$1 as afterAll, afterEach$1 as afterEach, beforeAll$1 as beforeAll, beforeEach$1 as beforeEach, check, expect$1 as expect };
|
|
20
|
+
}
|
|
21
|
+
type Assertion<A> = V.Assertion<void, A>;
|
|
22
|
+
/**
|
|
23
|
+
* Vitest's matchers for a value of type `A`, with the narrowed ones answering the refusal instead. `toBe` on
|
|
24
|
+
* an object, `toBeTypeOf` and `toBeInstanceOf` stay legal (R9).
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
type Lawful<A> = Omit<Assertion<A>, 'not' | NarrowVacuousName> & { readonly [Name in NarrowVacuousName]: PresenceRefusal<Name>; } & {
|
|
29
|
+
readonly not: LawfulNot<A>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
type LawfulNot<A> = Omit<Assertion<A>, 'not' | NarrowNegatedName> & { readonly [Name in NarrowNegatedName]: PresenceRefusal<Name>; };
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
interface LawfulCheck {
|
|
39
|
+
<A>(actual: A, message?: string): Lawful<A>;
|
|
40
|
+
<A>(message?: string): (actual: A) => Lawful<A>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Vitest's `expect` statics with the narrowed call signature and the fork's soft `soft`.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
type LawfulExpectStatic = LawfulCheck & {
|
|
48
|
+
readonly soft: LawfulCheck;
|
|
49
|
+
} & { readonly [K in Exclude<keyof V.ExpectStatic, 'soft'>]: V.ExpectStatic[K]; };
|
|
50
|
+
/**
|
|
51
|
+
* The pipeable form of a check: `check(actual, message)` and `check(message)(actual)`.
|
|
52
|
+
*
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
declare const check: {
|
|
56
|
+
<A>(actual: A, message?: string): Lawful<A>;
|
|
57
|
+
<A>(message?: string): (actual: A) => Lawful<A>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The fork's `expect`: soft within one Effect step, refusing the slop forms.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
declare const expect$1: LawfulExpectStatic;
|
|
65
|
+
type EachFirst = Parameters<typeof V.beforeEach>[0];
|
|
66
|
+
type AfterEachFirst = Parameters<typeof V.afterEach>[0];
|
|
67
|
+
type BeforeAllFirst = Parameters<typeof V.beforeAll>[0];
|
|
68
|
+
type AfterAllFirst = Parameters<typeof V.afterAll>[0];
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
declare const beforeEach$1: {
|
|
73
|
+
(fn: EachFirst, timeout?: number): void;
|
|
74
|
+
(timeout?: number): (fn: EachFirst) => void;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
declare const afterEach$1: {
|
|
80
|
+
(fn: AfterEachFirst, timeout?: number): void;
|
|
81
|
+
(timeout?: number): (fn: AfterEachFirst) => void;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
declare const beforeAll$1: {
|
|
87
|
+
(fn: BeforeAllFirst, timeout?: number): void;
|
|
88
|
+
(timeout?: number): (fn: BeforeAllFirst) => void;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
declare const afterAll$1: {
|
|
94
|
+
(fn: AfterAllFirst, timeout?: number): void;
|
|
95
|
+
(timeout?: number): (fn: AfterAllFirst) => void;
|
|
96
|
+
};
|
|
97
|
+
declare namespace owned_d_exports {
|
|
98
|
+
export { OwnedAssertions, RunBinding, captureRunBinding$1 as captureRunBinding, isOwned, owned$1 as owned, recordAssertion$1 as recordAssertion };
|
|
99
|
+
}
|
|
100
|
+
/** @internal */
|
|
101
|
+
declare const OwnedAssertions: Context.Reference<boolean>;
|
|
102
|
+
/** @internal */
|
|
103
|
+
declare const isOwned: () => boolean;
|
|
104
|
+
/** @internal */
|
|
105
|
+
declare const owned$1: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
106
|
+
/**
|
|
107
|
+
* Counts an Effect-native check as an assertion of the run it happens in, so the run's own gate sees it.
|
|
108
|
+
*
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
declare const recordAssertion$1: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* The test's run binding. `bind` hands it to an effect a library runs on a
|
|
114
|
+
* runtime of its own — its own scheduler, a worker, a simulation kernel — so
|
|
115
|
+
* the checks inside it count as this test's assertions, report softly, and see
|
|
116
|
+
* the same `owned` regions as the test itself.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
interface RunBinding {
|
|
121
|
+
readonly bind: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The run binding of the test the caller is executing in.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
declare const captureRunBinding$1: Effect.Effect<RunBinding>;
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/internal/property/defaults.d.ts
|
|
131
|
+
/** @internal The `test.provide` key the shared config fills with this run's tier's check options. */
|
|
132
|
+
declare const checkDefaultsKey = "@systemfsoftware/vitest:property-check";
|
|
133
|
+
/** @internal The check options a run supplies as its property default, minus `replay`. */
|
|
134
|
+
type ProvidedCheckDefaults = Omit<Arbitrary.CheckOptions, 'replay'>;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/internal/errors.schema.d.ts
|
|
137
|
+
declare const NonBooleanVerdict_base: Schema.Class<NonBooleanVerdict, Schema.TaggedStruct<"NonBooleanVerdict", {
|
|
138
|
+
readonly detail: Schema.String;
|
|
139
|
+
}>, import("effect/Cause").YieldableError>;
|
|
140
|
+
/** @internal */
|
|
141
|
+
declare class NonBooleanVerdict extends NonBooleanVerdict_base {
|
|
142
|
+
get message(): string;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/internal/property/impostor.d.ts
|
|
146
|
+
/**
|
|
147
|
+
* @internal The constant impostor of R12: a fake of the subject under test that
|
|
148
|
+
* returns the first output it ever produced, for every later call, whatever the
|
|
149
|
+
* input it was given.
|
|
150
|
+
*
|
|
151
|
+
* A property that still holds for the impostor does not constrain the subject.
|
|
152
|
+
* Whether that is fatal is a per-file question — a subject's impostor must be
|
|
153
|
+
* refuted by some property in its file — so this module builds the fake and
|
|
154
|
+
* collects the verdicts; the engine decides them once, when the file finishes
|
|
155
|
+
* (KTD10).
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* A value the fork hands over without inspecting: an argument to the subject, or one of its outputs.
|
|
159
|
+
*
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
type Opaque<A = unknown> = A;
|
|
163
|
+
/**
|
|
164
|
+
* A function under test: any argument, any output.
|
|
165
|
+
*
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
type SubjectFunction = (...values: ReadonlyArray<never>) => Opaque;
|
|
169
|
+
/**
|
|
170
|
+
* A record of functions under test; every member is replaced by a constant.
|
|
171
|
+
*
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
type MemberRecord = {
|
|
175
|
+
readonly [key: string]: SubjectFunction;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* The function under test, or a record of them.
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
type Subject = SubjectFunction | MemberRecord;
|
|
183
|
+
declare namespace kinds_d_exports {
|
|
184
|
+
export { LawApi, LawKind, LawSubject, MetamorphicRelation, deterministicHolds, idempotentHolds, invariantHolds, metamorphicHolds, modelHolds, roundTripHolds, spreadValues };
|
|
185
|
+
}
|
|
186
|
+
/** @internal */
|
|
187
|
+
type LawKind = 'model' | 'metamorphic' | 'roundTrip' | 'invariant' | 'idempotent' | 'deterministic';
|
|
188
|
+
/**
|
|
189
|
+
* A subject of a law kind: a function of the generated values.
|
|
190
|
+
*
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
type LawSubject<G extends Gens$1, A> = (...values: ReadonlyArray<ElementValues<G>>) => A;
|
|
194
|
+
/**
|
|
195
|
+
* A metamorphic relation: the input transform, and how the two outputs relate (structural equality by default).
|
|
196
|
+
*
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
interface MetamorphicRelation<G extends Gens$1, A> {
|
|
200
|
+
readonly transform: (...values: ReadonlyArray<ElementValues<G>>) => Values$1<G>;
|
|
201
|
+
readonly relate?: (original: A, transformed: A) => boolean;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The R13 law surface: four gated kinds and two declared exemptions.
|
|
205
|
+
*
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
interface LawApi {
|
|
209
|
+
readonly model: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, oracle: LawSubject<G, A>) => void;
|
|
210
|
+
readonly metamorphic: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, relation: MetamorphicRelation<G, A>) => void;
|
|
211
|
+
readonly roundTrip: <const G extends Gens$1, E, N extends number, S extends LawSubject<G, E>>(name: string, spec: PropertySpec$1<G, S, N>, decode: (encoded: E) => Values$1<G>) => void;
|
|
212
|
+
readonly invariant: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>, holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => void;
|
|
213
|
+
readonly idempotent: <const G extends Gens$1, N extends number, S extends (value: ElementValues<G>) => ElementValues<G>>(name: string, spec: PropertySpec$1<G, S, N>) => void;
|
|
214
|
+
readonly deterministic: <const G extends Gens$1, A, N extends number, S extends LawSubject<G, A>>(name: string, spec: PropertySpec$1<G, S, N>) => void;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The generated values as the argument list a law subject is called with.
|
|
218
|
+
*
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
declare const spreadValues: <G extends Gens$1>(values: Values$1<G>) => ReadonlyArray<ElementValues<G>>;
|
|
222
|
+
/** @internal */
|
|
223
|
+
declare const modelHolds: <G extends Gens$1, A>(oracle: LawSubject<G, A>) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
|
|
224
|
+
/** @internal */
|
|
225
|
+
declare const metamorphicHolds: <G extends Gens$1, A>(relation: MetamorphicRelation<G, A>) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
|
|
226
|
+
/** @internal */
|
|
227
|
+
declare const roundTripHolds: <G extends Gens$1, E>(decode: (encoded: E) => Values$1<G>) => (subject: LawSubject<G, E>, values: Values$1<G>) => boolean;
|
|
228
|
+
/** @internal */
|
|
229
|
+
declare const invariantHolds: <G extends Gens$1, A>(holds: (output: A, ...values: ReadonlyArray<ElementValues<G>>) => boolean) => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
|
|
230
|
+
/** @internal */
|
|
231
|
+
declare const idempotentHolds: <G extends Gens$1>() => (subject: (value: ElementValues<G>) => ElementValues<G>, values: Values$1<G>) => boolean;
|
|
232
|
+
/** @internal */
|
|
233
|
+
declare const deterministicHolds: <G extends Gens$1, A>() => (subject: LawSubject<G, A>, values: Values$1<G>) => boolean;
|
|
234
|
+
declare namespace engine_d_exports {
|
|
235
|
+
export { ArbitraryInput, CoveragePredicate, ElementValues, Gens$1 as Gens, PropApi, PropertyRuntime, PropertySpec$1 as PropertySpec, PropertySubject$1 as PropertySubject, Values$1 as Values, makeProperty };
|
|
236
|
+
}
|
|
237
|
+
/** @internal */
|
|
238
|
+
type ArbitraryInput = Schema$1.Top | Arbitrary.Arbitrary<Schema$1.Top['Type']>;
|
|
239
|
+
/** @internal */
|
|
240
|
+
type Gens$1 = ReadonlyArray<ArbitraryInput> | {
|
|
241
|
+
readonly [key: string]: ArbitraryInput;
|
|
242
|
+
};
|
|
243
|
+
type Generated<I> = I extends Schema$1.Schema<infer T> ? T : I extends Arbitrary.Arbitrary<infer A> ? A : never;
|
|
244
|
+
/** @internal */
|
|
245
|
+
type Values$1<G extends Gens$1> = { readonly [K in keyof G]: Generated<G[K]>; };
|
|
246
|
+
/** @internal */
|
|
247
|
+
type ElementValues<G extends Gens$1> = G extends ReadonlyArray<ArbitraryInput> ? Generated<G[number]> : never;
|
|
248
|
+
/** @internal */
|
|
249
|
+
type PropertySubject$1 = Subject;
|
|
250
|
+
/** @internal */
|
|
251
|
+
type CoveragePredicate<G extends Gens$1> = (...values: ReadonlyArray<ElementValues<G>>) => boolean;
|
|
252
|
+
type PropertyRuns<N extends number> = number extends N ? number : `${N}` extends `-${bigint}` ? never : `${N}` extends `${bigint}` ? (N extends 0 ? never : N) : never;
|
|
253
|
+
/** @internal */
|
|
254
|
+
interface PropertySpec$1<G extends Gens$1, S extends PropertySubject$1, N extends number> {
|
|
255
|
+
readonly of: G;
|
|
256
|
+
readonly subject: S;
|
|
257
|
+
/**
|
|
258
|
+
* The property's own run count. Omitted, the configured default applies; when the run provides none,
|
|
259
|
+
* the built-in default of 100 does.
|
|
260
|
+
*/
|
|
261
|
+
readonly runs?: N & PropertyRuns<N>;
|
|
262
|
+
/** Labelled input predicates, each with the minimum share of runs it must see (R14). */
|
|
263
|
+
readonly cover?: Readonly<Record<string, readonly [CoveragePredicate<G>, number]>>;
|
|
264
|
+
/** The property's own check options, merged field by field over the provided and built-in defaults. */
|
|
265
|
+
readonly arbitrary?: Arbitrary.CheckOptions;
|
|
266
|
+
}
|
|
267
|
+
/** @internal */
|
|
268
|
+
interface PropertyRuntime<R> {
|
|
269
|
+
/** Registers the property's program; the runtime runs it inside the test it registers, under that test's binding. */
|
|
270
|
+
readonly register: (name: string, program: () => Effect.Effect<void, Cause.Cause<NonBooleanVerdict>, never>) => void;
|
|
271
|
+
readonly provide: <A, E>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, never>;
|
|
272
|
+
}
|
|
273
|
+
/** @internal */
|
|
274
|
+
interface PropApi<R> {
|
|
275
|
+
readonly prop: <const G extends Gens$1, S extends PropertySubject$1, N extends number>(name: string, spec: PropertySpec$1<G, S, N>, holds: (subject: S, values: Values$1<G>) => boolean) => void;
|
|
276
|
+
readonly effectProp: <const G extends Gens$1, S extends PropertySubject$1, N extends number, E>(name: string, spec: PropertySpec$1<G, S, N>, holds: (subject: S, values: Values$1<G>) => Effect.Effect<boolean, E, R>) => void;
|
|
277
|
+
readonly law: LawApi;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The property surface over one runtime: `prop`, `effectProp`, and the R13 law kinds routed through the gate.
|
|
281
|
+
*
|
|
282
|
+
* @internal
|
|
283
|
+
*/
|
|
284
|
+
declare const makeProperty: <R>(runtime: PropertyRuntime<R>) => PropApi<R>;
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/internal/virtual-time.d.ts
|
|
287
|
+
/** @internal */
|
|
288
|
+
interface VirtualRuntime {
|
|
289
|
+
readonly clock: Clock.Clock;
|
|
290
|
+
readonly scheduler: Scheduler.Scheduler;
|
|
291
|
+
/** @internal */
|
|
292
|
+
readonly observe: Effect.Effect<void, never, never>;
|
|
293
|
+
/** @internal */
|
|
294
|
+
readonly end: Effect.Effect<void, never, never>;
|
|
295
|
+
}
|
|
296
|
+
declare namespace runner_d_exports {
|
|
297
|
+
export { BlockRegistrar, LayerOptions$1 as LayerOptions, NestedLayer, RunEnv, TestContext, addEqualityTesters$1 as addEqualityTesters, describeWrapped$1 as describeWrapped, flakyTest$1 as flakyTest, hookTimeout, layer$1 as layer, makeMethods$1 as makeMethods, perRun, prop$1 as prop, realTime, testEnv, testOptions };
|
|
298
|
+
}
|
|
299
|
+
/** @internal */
|
|
300
|
+
type TestContext = TestConsole.TestConsole | TestClock.TestClock;
|
|
301
|
+
/** @internal */
|
|
302
|
+
declare const addEqualityTesters$1: () => void;
|
|
303
|
+
/** @internal */
|
|
304
|
+
declare const testOptions: (timeout?: number | V.TestOptions) => V.TestOptions;
|
|
305
|
+
/** @internal */
|
|
306
|
+
declare const hookTimeout: (timeout?: Duration.Input) => number | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* How a run arms the step boundary: a test's `stopCheckOf` interrupts it once one of its checks failed (R6),
|
|
309
|
+
* and `neverStop` leaves a property's verdict returned, so a `false` one still shrinks (R6, U4).
|
|
310
|
+
*/
|
|
311
|
+
type StopPolicy = (ctx: V.TestContext | undefined) => (() => boolean) | undefined;
|
|
312
|
+
/** @internal */
|
|
313
|
+
interface RunEnv {
|
|
314
|
+
readonly runtime: VirtualRuntime | undefined;
|
|
315
|
+
readonly owned: boolean;
|
|
316
|
+
/** How the runs of this env arm the step boundary. */
|
|
317
|
+
readonly stop: StopPolicy;
|
|
318
|
+
}
|
|
319
|
+
/** @internal */
|
|
320
|
+
declare const realTime: RunEnv;
|
|
321
|
+
/** @internal */
|
|
322
|
+
declare const perRun: () => RunEnv;
|
|
323
|
+
/** @internal */
|
|
324
|
+
declare const testEnv: (env: RunEnv) => Layer.Layer<TestConsole.TestConsole, never, never>;
|
|
325
|
+
/** @internal */
|
|
326
|
+
declare const prop$1: Vitest.Methods['prop'];
|
|
327
|
+
/**
|
|
328
|
+
* Options for the top-level `layer` and for `it.layer` inside a `Methods` block.
|
|
329
|
+
*
|
|
330
|
+
* @internal
|
|
331
|
+
*/
|
|
332
|
+
type LayerOptions$1 = {
|
|
333
|
+
readonly concurrent?: boolean;
|
|
334
|
+
readonly memoMap?: Layer.MemoMap;
|
|
335
|
+
readonly timeout?: Duration.Input;
|
|
336
|
+
readonly excludeTestServices?: boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Share one build of these layers across every test of the block, instead of giving each test its own
|
|
339
|
+
* fresh build. The only way to share; nested blocks inherit it.
|
|
340
|
+
*/
|
|
341
|
+
readonly shared?: boolean;
|
|
342
|
+
};
|
|
343
|
+
type BlockBody<R> = (it: Vitest.MethodsNonLive<R>) => void;
|
|
344
|
+
/** @internal */
|
|
345
|
+
type BlockRegistrar<R> = {
|
|
346
|
+
(f: BlockBody<R>): void;
|
|
347
|
+
(name: string, f: BlockBody<R>): void;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* The nested layer a block's own `it.layer` opens, and the options it accepts.
|
|
351
|
+
*
|
|
352
|
+
* @internal
|
|
353
|
+
*/
|
|
354
|
+
type NestedLayer = {
|
|
355
|
+
readonly concurrent?: boolean;
|
|
356
|
+
readonly timeout?: Duration.Input;
|
|
357
|
+
/** Share one build across this nested block's tests; inherited from a shared parent block. */
|
|
358
|
+
readonly shared?: boolean;
|
|
359
|
+
};
|
|
360
|
+
/** @internal */
|
|
361
|
+
declare const layer$1: {
|
|
362
|
+
<R, E>(layer_: Layer.Layer<R, E>, options?: LayerOptions$1): BlockRegistrar<R>;
|
|
363
|
+
<R, E>(options?: LayerOptions$1): (layer_: Layer.Layer<R, E>) => BlockRegistrar<R>;
|
|
364
|
+
};
|
|
365
|
+
/** @internal */
|
|
366
|
+
declare const flakyTest$1: {
|
|
367
|
+
<A, E, R>(self: Effect.Effect<A, E, R | Scope.Scope>, timeout?: Duration.Input): Effect.Effect<A, never, R>;
|
|
368
|
+
(timeout?: Duration.Input): <A, E, R>(self: Effect.Effect<A, E, R | Scope.Scope>) => Effect.Effect<A, never, R>;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* The fork's `it`: Vitest's test API with the fork's Effect lanes and lawful property lanes attached,
|
|
372
|
+
* callable data-first (`it(name, body)`) or data-last (`it(body, options?)(name)`).
|
|
373
|
+
*
|
|
374
|
+
* @internal
|
|
375
|
+
*/
|
|
376
|
+
declare const makeMethods$1: (it: V.TestAPI) => Vitest.Methods;
|
|
377
|
+
/** @internal */
|
|
378
|
+
/** @internal */
|
|
379
|
+
/** @internal */
|
|
380
|
+
/** @internal */
|
|
381
|
+
declare const describeWrapped$1: {
|
|
382
|
+
(name: string, f: (it: Vitest.Methods) => void): V.SuiteCollector;
|
|
383
|
+
(f: (it: Vitest.Methods) => void): (name: string) => V.SuiteCollector;
|
|
384
|
+
};
|
|
385
|
+
declare namespace mod_d_exports {
|
|
386
|
+
export { API, Methods, MethodsNonLive, Vitest, VitestTestContext, addEqualityTesters, afterAll, afterEach, beforeAll, beforeEach, captureRunBinding, describe, describeWrapped, effect, expect, flakyTest, it, layer, live, makeMethods, owned, prop, recordAssertion, vitestTestContextKey };
|
|
387
|
+
}
|
|
388
|
+
import * as import_vitest from "vitest";
|
|
389
|
+
declare module 'vitest' {
|
|
390
|
+
interface ProvidedContext {
|
|
391
|
+
[checkDefaultsKey]?: ProvidedCheckDefaults;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Vitest's test API, with its call signatures paired: each data-first form has its data-last twin, so
|
|
396
|
+
* `it(name, body)`, `it(body)(name)`, `it(name, options, body)` and `it(options, body)(name)` all work.
|
|
397
|
+
*
|
|
398
|
+
* @since 4.0.0
|
|
399
|
+
*/
|
|
400
|
+
export type API = Omit<V.TestAPI<{}>, never> & {
|
|
401
|
+
/**
|
|
402
|
+
* Data-last: `it(body, timeout?)(name)`. Declared before the data-first forms so that a bare
|
|
403
|
+
* `it(body)` resolves here, which is where the runtime routes a first argument that is not a name.
|
|
404
|
+
*
|
|
405
|
+
* @since 4.0.0
|
|
406
|
+
*/
|
|
407
|
+
<ExtraContext extends {}>(fn?: V.TestFunction<ExtraContext>, options?: number): (name: string | Function) => void;
|
|
408
|
+
/**
|
|
409
|
+
* @since 4.0.0
|
|
410
|
+
*/
|
|
411
|
+
<ExtraContext extends {}>(name: string | Function, fn: V.TestFunction<ExtraContext> | undefined, options?: number): void;
|
|
412
|
+
/**
|
|
413
|
+
* Data-last: `it(options, body)(name)`.
|
|
414
|
+
*
|
|
415
|
+
* @since 4.0.0
|
|
416
|
+
*/
|
|
417
|
+
<ExtraContext extends {}>(options: V.TestOptions, fn?: V.TestFunction<ExtraContext>): (name: string | Function) => void;
|
|
418
|
+
/**
|
|
419
|
+
* @since 4.0.0
|
|
420
|
+
*/
|
|
421
|
+
<ExtraContext extends {}>(name: string | Function, options: V.TestOptions, fn?: V.TestFunction<ExtraContext>): void;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* @since 4.0.0
|
|
425
|
+
*/
|
|
426
|
+
export declare namespace Vitest {
|
|
427
|
+
/**
|
|
428
|
+
* @since 4.0.0
|
|
429
|
+
*/
|
|
430
|
+
interface TestFunction<A, E, R, TestArgs extends TestContextWithValues> {
|
|
431
|
+
(...args: TestArgs): Effect.Effect<A, E, R>;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @since 4.0.0
|
|
435
|
+
*/
|
|
436
|
+
type TestContextOnly = [V.TestContext];
|
|
437
|
+
/**
|
|
438
|
+
* @since 4.0.0
|
|
439
|
+
*/
|
|
440
|
+
type TestContextWithValues = [V.TestContext] | [V.TestContext | object] | [V.TestContext | object, V.TestContext] | [V.TestContext | object, V.TestContext & object];
|
|
441
|
+
/**
|
|
442
|
+
* @since 4.0.0
|
|
443
|
+
*/
|
|
444
|
+
interface Test<R> {
|
|
445
|
+
<A, E>(name: string, self: TestFunction<A, E, R, [V.TestContext]>, timeout?: number | V.TestOptions): void;
|
|
446
|
+
/**
|
|
447
|
+
* Data-last: `it.effect(self, timeout?)(name)`.
|
|
448
|
+
*
|
|
449
|
+
* @since 4.0.0
|
|
450
|
+
*/
|
|
451
|
+
<A, E>(self: TestFunction<A, E, R, [V.TestContext]>, timeout?: number | V.TestOptions): (name: string) => void;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* A generated input: a Schema, or an Arbitrary of an already-generated type.
|
|
455
|
+
*
|
|
456
|
+
* @since 4.0.0
|
|
457
|
+
*/
|
|
458
|
+
type ArbitraryInput = ArbitraryInput;
|
|
459
|
+
/**
|
|
460
|
+
* The inputs a property generates: a tuple or record of Schemas or Arbitraries.
|
|
461
|
+
*
|
|
462
|
+
* @since 4.0.0
|
|
463
|
+
*/
|
|
464
|
+
type Gens = Gens$1;
|
|
465
|
+
/**
|
|
466
|
+
* The types a `Gens` generates: a tuple when `of` is a tuple, a record when it is a record.
|
|
467
|
+
*
|
|
468
|
+
* @since 4.0.0
|
|
469
|
+
*/
|
|
470
|
+
type Values<G extends Gens> = Values$1<G>;
|
|
471
|
+
/**
|
|
472
|
+
* The function under test, handed to the property rather than imported into it.
|
|
473
|
+
*
|
|
474
|
+
* @since 4.0.0
|
|
475
|
+
*/
|
|
476
|
+
type PropertySubject = PropertySubject$1;
|
|
477
|
+
/**
|
|
478
|
+
* A property's subject, its optional budget and its coverage classes. `runs`, when given, must be a
|
|
479
|
+
* positive integer; omitted, the effective check options merge the property's fields over the configured
|
|
480
|
+
* default (`test.provide`) over the built-in `runs: 100`. `cover` declares the coverage classes of R14.
|
|
481
|
+
*
|
|
482
|
+
* @since 4.0.0
|
|
483
|
+
*/
|
|
484
|
+
type PropertySpec<G extends Gens, S extends PropertySubject, N extends number> = PropertySpec$1<G, S, N>;
|
|
485
|
+
/**
|
|
486
|
+
* The block a layer opens: `layer(L)(body)` or `layer(L)("name", body)`.
|
|
487
|
+
*
|
|
488
|
+
* @since 4.0.0
|
|
489
|
+
*/
|
|
490
|
+
type LayerBlock<R> = BlockRegistrar<R>;
|
|
491
|
+
/**
|
|
492
|
+
* The nested layer a block's own `it.layer` opens.
|
|
493
|
+
*
|
|
494
|
+
* @since 4.0.0
|
|
495
|
+
*/
|
|
496
|
+
type NestedLayerOptions = NestedLayer;
|
|
497
|
+
/**
|
|
498
|
+
* Options for the top-level `layer` and for `it.layer` inside a `Methods` block.
|
|
499
|
+
*
|
|
500
|
+
* @since 4.0.0
|
|
501
|
+
*/
|
|
502
|
+
type LayerOptions = LayerOptions$1;
|
|
503
|
+
/**
|
|
504
|
+
* A layer's block, data-first or data-last.
|
|
505
|
+
*
|
|
506
|
+
* @since 4.0.0
|
|
507
|
+
*/
|
|
508
|
+
interface LayerOf<R, Options> {
|
|
509
|
+
<R2, E>(layer: Layer.Layer<R2, E, R>, options?: Options): LayerBlock<R | R2>;
|
|
510
|
+
(options?: Options): <R2, E>(layer: Layer.Layer<R2, E, R>) => LayerBlock<R | R2>;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* A flaky Effect, data-first or data-last.
|
|
514
|
+
*
|
|
515
|
+
* @since 4.0.0
|
|
516
|
+
*/
|
|
517
|
+
type FlakyTest = typeof flakyTest$1;
|
|
518
|
+
/**
|
|
519
|
+
* @since 4.0.0
|
|
520
|
+
*/
|
|
521
|
+
interface Tester<R> extends Vitest.Test<R> {
|
|
522
|
+
skip: Vitest.Test<R>;
|
|
523
|
+
skipIf: (condition: boolean) => Vitest.Test<R>;
|
|
524
|
+
runIf: (condition: boolean) => Vitest.Test<R>;
|
|
525
|
+
only: Vitest.Test<R>;
|
|
526
|
+
each: <T extends object>(cases: ReadonlyArray<T>) => <A, E>(name: string, self: TestFunction<A, E, R, TestContextWithValues & [V.TestContext | T]>, timeout?: number | V.TestOptions) => void;
|
|
527
|
+
fails: Vitest.Test<R>;
|
|
528
|
+
/**
|
|
529
|
+
* Runs a property that names its subject and carries a budget, on the Effect lane.
|
|
530
|
+
*
|
|
531
|
+
* **Details**
|
|
532
|
+
*
|
|
533
|
+
* `spec.subject` is handed to `holds` instead of being imported into the property. `holds` returns an
|
|
534
|
+
* `Effect` of its verdict: `true` holds, `false` falsifies and triggers shrinking, and any typed failure
|
|
535
|
+
* falsifies the property with its cause. A verdict that is not a literal boolean fails as
|
|
536
|
+
* `NonBooleanVerdict`; a `runs` that is not a positive integer fails as `InvalidBudget`. `runs` is optional:
|
|
537
|
+
* the property's own fields win over the configured default (`test.provide`) over `runs: 100`. After the
|
|
538
|
+
* property holds, it is run again against a constant impostor of its subject; the file fails as
|
|
539
|
+
* `VacuousProperty` unless some property in it refutes that impostor.
|
|
540
|
+
*
|
|
541
|
+
* The old positional form `it.effect.prop(name, [arbitraries], predicate)` is refused.
|
|
542
|
+
*
|
|
543
|
+
* @since 4.0.0
|
|
544
|
+
*/
|
|
545
|
+
prop: <const G extends Gens, S extends PropertySubject, N extends number, E>(name: string, spec: PropertySpec<G, S, N>, holds: (subject: S, values: Values<G>) => Effect.Effect<boolean, E, R>) => void;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @since 4.0.0
|
|
549
|
+
*/
|
|
550
|
+
interface MethodsNonLive<R = never> extends API {
|
|
551
|
+
readonly effect: Vitest.Tester<R | Scope.Scope>;
|
|
552
|
+
readonly flakyTest: FlakyTest;
|
|
553
|
+
readonly layer: LayerOf<R, NestedLayerOptions>;
|
|
554
|
+
/**
|
|
555
|
+
* Runs a property that names its subject and carries a budget, on the sync lane.
|
|
556
|
+
*
|
|
557
|
+
* **Details**
|
|
558
|
+
*
|
|
559
|
+
* `spec.subject` is handed to `holds` instead of being imported into the property. `holds` returns a literal
|
|
560
|
+
* `true`/`false` verdict: `false` falsifies and triggers shrinking. A verdict that is not a boolean — an
|
|
561
|
+
* `Effect`, an `expect()`, an object — fails as `NonBooleanVerdict`, and a `runs` that is not a positive
|
|
562
|
+
* integer fails as `InvalidBudget`. `runs` is optional: the property's own fields win over the configured
|
|
563
|
+
* default (`test.provide`) over `runs: 100`. After the property holds, it is run again against a constant
|
|
564
|
+
* impostor of its subject; the file fails as `VacuousProperty` unless some property in it refutes that impostor.
|
|
565
|
+
*
|
|
566
|
+
* The old positional form `it.prop(name, [arbitraries], predicate)` is refused.
|
|
567
|
+
*
|
|
568
|
+
* @since 4.0.0
|
|
569
|
+
*/
|
|
570
|
+
readonly prop: {
|
|
571
|
+
<const G extends Gens, S extends PropertySubject, N extends number>(name: string, spec: PropertySpec<G, S, N>, holds: (subject: S, values: Values<G>) => boolean): void;
|
|
572
|
+
<const G extends Gens, S extends PropertySubject, N extends number>(spec: PropertySpec<G, S, N>, holds: (subject: S, values: Values<G>) => boolean): (name: string) => void;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* The R13 law kinds: `model`, `metamorphic`, `roundTrip` and `invariant` are gated like `prop`;
|
|
576
|
+
* `idempotent` and `deterministic` skip the impostor gate and are reported as exempt.
|
|
577
|
+
*
|
|
578
|
+
* @since 4.0.0
|
|
579
|
+
*/
|
|
580
|
+
readonly law: LawApi;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* @since 4.0.0
|
|
584
|
+
*/
|
|
585
|
+
interface Methods<R = never> extends MethodsNonLive<R> {
|
|
586
|
+
readonly live: Vitest.Tester<Scope.Scope | R>;
|
|
587
|
+
readonly layer: LayerOf<R, LayerOptions>;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* @since 4.0.0
|
|
592
|
+
*/
|
|
593
|
+
export type MethodsNonLive<R = never> = Vitest.MethodsNonLive<R>;
|
|
594
|
+
/**
|
|
595
|
+
* @since 4.0.0
|
|
596
|
+
*/
|
|
597
|
+
export type Methods<R = never> = Vitest.Methods<R>;
|
|
598
|
+
/**
|
|
599
|
+
* @since 4.0.0
|
|
600
|
+
*/
|
|
601
|
+
export declare const addEqualityTesters: () => void;
|
|
602
|
+
/**
|
|
603
|
+
* @since 4.0.0
|
|
604
|
+
*/
|
|
605
|
+
export declare const effect: Vitest.Tester<Scope.Scope>;
|
|
606
|
+
/**
|
|
607
|
+
* @since 4.0.0
|
|
608
|
+
*/
|
|
609
|
+
export declare const live: Vitest.Tester<Scope.Scope>;
|
|
610
|
+
/**
|
|
611
|
+
* Share a `Layer` between multiple tests, optionally wrapping
|
|
612
|
+
* the tests in a `describe` block if a name is provided.
|
|
613
|
+
*
|
|
614
|
+
* Named layers accept `concurrent` to override inherited suite concurrency.
|
|
615
|
+
* Anonymous layers always inherit the enclosing suite's concurrency.
|
|
616
|
+
* Use `ctx.expect` in concurrent tests for test-local snapshots and assertion counts.
|
|
617
|
+
*
|
|
618
|
+
* @since 4.0.0
|
|
619
|
+
*
|
|
620
|
+
* ```ts
|
|
621
|
+
* import { assert, layer } from "@systemfsoftware/vitest"
|
|
622
|
+
* import { Effect, Layer, Context } from "effect"
|
|
623
|
+
*
|
|
624
|
+
* class Foo extends Context.Service<Foo, "foo">()("Foo") {
|
|
625
|
+
* static layer = Layer.succeed(Foo, "foo")
|
|
626
|
+
* }
|
|
627
|
+
*
|
|
628
|
+
* class Bar extends Context.Service<Bar, "bar">()("Bar") {
|
|
629
|
+
* static layer = Layer.effect(
|
|
630
|
+
* Bar,
|
|
631
|
+
* Effect.map(Foo, () => "bar" as const)
|
|
632
|
+
* )
|
|
633
|
+
* }
|
|
634
|
+
*
|
|
635
|
+
* layer(Foo.layer)("layer", (it) => {
|
|
636
|
+
* it.effect("adds context", () =>
|
|
637
|
+
* Effect.gen(function*() {
|
|
638
|
+
* const foo = yield* Foo
|
|
639
|
+
* assert.strictEqual(foo, "foo")
|
|
640
|
+
* }))
|
|
641
|
+
*
|
|
642
|
+
* it.layer(Bar.layer)("nested", (it) => {
|
|
643
|
+
* it.effect("adds context", () =>
|
|
644
|
+
* Effect.gen(function*() {
|
|
645
|
+
* const foo = yield* Foo
|
|
646
|
+
* const bar = yield* Bar
|
|
647
|
+
* assert.strictEqual(foo, "foo")
|
|
648
|
+
* assert.strictEqual(bar, "bar")
|
|
649
|
+
* }))
|
|
650
|
+
* })
|
|
651
|
+
* })
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
export declare const layer: Vitest.LayerOf<never, Vitest.LayerOptions>;
|
|
655
|
+
/**
|
|
656
|
+
* @since 4.0.0
|
|
657
|
+
*/
|
|
658
|
+
export declare const flakyTest: Vitest.FlakyTest;
|
|
659
|
+
/**
|
|
660
|
+
* @since 4.0.0
|
|
661
|
+
*/
|
|
662
|
+
export declare const prop: Vitest.Methods['prop'];
|
|
663
|
+
/**
|
|
664
|
+
* @since 4.0.0
|
|
665
|
+
*/
|
|
666
|
+
export declare const owned: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
667
|
+
/**
|
|
668
|
+
* @since 4.0.0
|
|
669
|
+
*/
|
|
670
|
+
export declare const recordAssertion: () => void;
|
|
671
|
+
/**
|
|
672
|
+
* The run binding of the test the effect is executing in. `bind` re-provides it
|
|
673
|
+
* to an effect a library runs on a runtime of its own — its own scheduler, a
|
|
674
|
+
* worker, a simulation kernel — so the checks inside it count as this test's
|
|
675
|
+
* assertions, report softly, and see the same `owned` regions as the test.
|
|
676
|
+
*
|
|
677
|
+
* @since 4.0.0
|
|
678
|
+
*/
|
|
679
|
+
export declare const captureRunBinding: Effect.Effect<RunBinding>;
|
|
680
|
+
/**
|
|
681
|
+
* The key the running test's context is published under. A library that carries its own view of the task
|
|
682
|
+
* context builds that view on this key, so the context a case lane sees and a property lane sees agree.
|
|
683
|
+
*
|
|
684
|
+
* @since 4.0.0
|
|
685
|
+
*/
|
|
686
|
+
export declare const vitestTestContextKey: string;
|
|
687
|
+
/**
|
|
688
|
+
* The running Vitest `TestContext`, provided on every test the fork runs — the Effect lanes, both property
|
|
689
|
+
* lanes, and each `it.each` row. It is `null` outside a run.
|
|
690
|
+
*
|
|
691
|
+
* @since 4.0.0
|
|
692
|
+
*/
|
|
693
|
+
export declare const VitestTestContext: Context.Reference<V.TestContext | null>;
|
|
694
|
+
/**
|
|
695
|
+
* @since 4.0.0
|
|
696
|
+
*/
|
|
697
|
+
export declare const it: Vitest.Methods;
|
|
698
|
+
/**
|
|
699
|
+
* @since 4.0.0
|
|
700
|
+
*/
|
|
701
|
+
export declare const makeMethods: (it: V.TestAPI) => Vitest.Methods;
|
|
702
|
+
/**
|
|
703
|
+
* @since 4.0.0
|
|
704
|
+
*/
|
|
705
|
+
export declare const describeWrapped: {
|
|
706
|
+
(name: string, f: (it: Vitest.Methods) => void): V.SuiteCollector;
|
|
707
|
+
(f: (it: Vitest.Methods) => void): (name: string) => V.SuiteCollector;
|
|
708
|
+
};
|
|
709
|
+
export declare const describe: {
|
|
710
|
+
(name: string, f: (it: Vitest.Methods) => void): V.SuiteCollector;
|
|
711
|
+
(f: (it: Vitest.Methods) => void): (name: string) => V.SuiteCollector;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* The fork's `expect`: soft within one Effect step, refusing the slop forms.
|
|
715
|
+
*
|
|
716
|
+
* @since 4.0.0
|
|
717
|
+
*/
|
|
718
|
+
export declare const expect: typeof expect$1;
|
|
719
|
+
/**
|
|
720
|
+
* @since 4.0.0
|
|
721
|
+
*/
|
|
722
|
+
export declare const beforeEach: typeof beforeEach$1;
|
|
723
|
+
/**
|
|
724
|
+
* @since 4.0.0
|
|
725
|
+
*/
|
|
726
|
+
export declare const afterEach: typeof afterEach$1;
|
|
727
|
+
/**
|
|
728
|
+
* @since 4.0.0
|
|
729
|
+
*/
|
|
730
|
+
export declare const beforeAll: typeof beforeAll$1;
|
|
731
|
+
/**
|
|
732
|
+
* @since 4.0.0
|
|
733
|
+
*/
|
|
734
|
+
export declare const afterAll: typeof afterAll$1;
|
|
735
|
+
//#endregion
|