@systemfsoftware/vitest 0.0.0 → 0.1.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 +6 -0
- package/README.md +113 -61
- package/dist/TestClock.d.ts +1 -1
- package/dist/checks-DiuzHhQM.d.ts +232 -0
- package/dist/guard-BocOhXt2.mjs +246 -0
- package/dist/guard.d.ts +2 -0
- package/dist/guard.mjs +19 -0
- package/dist/index.d.ts +201 -287
- package/dist/index.mjs +353 -562
- package/dist/integration.d.ts +37 -0
- package/dist/integration.mjs +38 -0
- package/dist/test-context-hvSoKLtw.mjs +206 -0
- package/package.json +9 -9
- package/dist/refusals-BQtDszyU.mjs +0 -32
- package/dist/refusals-_6e3GzVK.d.ts +0 -37
- package/dist/refusals.d.ts +0 -3
- package/dist/refusals.mjs +0 -3
- package/dist/utils.d.ts +0 -197
- package/dist/utils.mjs +0 -227
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as Expect, n as AssertedShape, r as Check, t as Asserted } from "./checks-DiuzHhQM.js";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
//#region src/integration.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A flow that asserts more than once marks each assertion point with this, so the check after it is that
|
|
7
|
+
* state's one check (KTD5).
|
|
8
|
+
*
|
|
9
|
+
* @since 4.0.0
|
|
10
|
+
*/
|
|
11
|
+
export declare const step: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R | Asserted>;
|
|
12
|
+
/**
|
|
13
|
+
* The test's run, as a library hands it to a runtime of its own: `bind` provides what a check reads off the
|
|
14
|
+
* test's own fiber — the ledger — so the checks the other runtime runs count as this test's assertions, and the
|
|
15
|
+
* bound effect no longer requires `Asserted`, which is what lets it cross into a runtime that cannot know it.
|
|
16
|
+
*
|
|
17
|
+
* A runtime of its own re-runs the bound effect — a kernel explores a baseline and then its seeded replays — and
|
|
18
|
+
* executing the bound effect opens a new observed state before it runs, so each execution is a run. `bind`
|
|
19
|
+
* resets nothing on its own: the step runs when the bound effect is executed. A runtime that re-runs a check
|
|
20
|
+
* without executing the bound effect has opened no state, so its second check is refused, as any two checks on
|
|
21
|
+
* one state are. One check per execution, and two checks inside one execution are still refused.
|
|
22
|
+
*
|
|
23
|
+
* @since 4.0.0
|
|
24
|
+
*/
|
|
25
|
+
export interface RunBinding {
|
|
26
|
+
readonly bind: <A, E, R>(self: Effect.Effect<A, E, R | Asserted>) => Effect.Effect<A, E, R>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The run binding of the test the caller is executing in: the ledger its checks count on, and the running task
|
|
30
|
+
* context. Capture it from inside a test — the capture requires `Asserted`, so a library cannot mistake a run
|
|
31
|
+
* binding for something the outside has — and bind the effect before handing it to a runtime of its own.
|
|
32
|
+
*
|
|
33
|
+
* @since 4.0.0
|
|
34
|
+
*/
|
|
35
|
+
export declare const captureRunBinding: Effect.Effect<RunBinding, never, Asserted>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export type { Asserted, AssertedShape, Check, Expect };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { r as Asserted, t as VitestTestContext } from "./test-context-hvSoKLtw.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
//#region src/integration.ts
|
|
6
|
+
/**
|
|
7
|
+
* The integration entry (KTD5): the types a library writes its verdicts with, the marker it calls between the
|
|
8
|
+
* observations of one flow, and the binding it carries onto a runtime of its own.
|
|
9
|
+
*
|
|
10
|
+
* @since 4.0.0
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* A flow that asserts more than once marks each assertion point with this, so the check after it is that
|
|
14
|
+
* state's one check (KTD5).
|
|
15
|
+
*
|
|
16
|
+
* @since 4.0.0
|
|
17
|
+
*/
|
|
18
|
+
const step = (self) => Effect.flatMap(Asserted, (asserted) => Effect.andThen(Effect.sync(() => asserted.step()), self));
|
|
19
|
+
const boundContext = (self, ctx) => Option.match(Option.fromNullishOr(ctx), {
|
|
20
|
+
onNone: () => self,
|
|
21
|
+
onSome: (value) => Effect.provideService(self, VitestTestContext, value)
|
|
22
|
+
});
|
|
23
|
+
const openedRun = (self, asserted) => Effect.andThen(Effect.sync(() => asserted.step()), self);
|
|
24
|
+
const bindingOf = (asserted, ctx) => ({ bind: (self) => boundContext(Effect.provideService(openedRun(self, asserted), Asserted, asserted), ctx) });
|
|
25
|
+
/**
|
|
26
|
+
* The run binding of the test the caller is executing in: the ledger its checks count on, and the running task
|
|
27
|
+
* context. Capture it from inside a test — the capture requires `Asserted`, so a library cannot mistake a run
|
|
28
|
+
* binding for something the outside has — and bind the effect before handing it to a runtime of its own.
|
|
29
|
+
*
|
|
30
|
+
* @since 4.0.0
|
|
31
|
+
*/
|
|
32
|
+
const captureRunBinding = Effect.gen(function* () {
|
|
33
|
+
const asserted = yield* Asserted;
|
|
34
|
+
const ctx = Option.getOrUndefined(yield* Effect.serviceOption(VitestTestContext));
|
|
35
|
+
return bindingOf(asserted, ctx);
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { captureRunBinding, step };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
|
|
2
|
+
import { a as booleanRefusal, b as refusedText, c as negatedText, m as refusePiecewise, s as neededText, t as authorize, u as refusalOf } from "./guard-BocOhXt2.mjs";
|
|
3
|
+
import * as V from "vitest";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
//#region src/internal/checks.ts
|
|
8
|
+
/**
|
|
9
|
+
* The checks a test receives as its callback parameter. There is no importable `expect`: the only one in reach is
|
|
10
|
+
* the one the runner hands this test, so it is bound to this test by construction, not by a lookup.
|
|
11
|
+
*
|
|
12
|
+
* Every matcher returns a `Check`: an Effect that needs `Asserted`, a service only the runner provides.
|
|
13
|
+
* - A check that is not yielded is a floating Effect: `@effect/language-service` `floatingEffect` fails the build.
|
|
14
|
+
* - A body that yields no check has no `Asserted` in its requirements: the test signature refuses it.
|
|
15
|
+
* - A check run outside a test has nothing providing `Asserted`: a type error.
|
|
16
|
+
*
|
|
17
|
+
* @since 4.0.0
|
|
18
|
+
*/
|
|
19
|
+
/** @internal */
|
|
20
|
+
var Asserted = class extends Context.Service()("@systemfsoftware/vitest/Asserted") {};
|
|
21
|
+
const branded = /* @__PURE__ */ new WeakSet();
|
|
22
|
+
const isObject = (value) => typeof value === "object" && value !== null;
|
|
23
|
+
/** @internal */
|
|
24
|
+
const isCheck = (value) => isObject(value) && branded.has(value);
|
|
25
|
+
const makeCheck = (judgement, written) => {
|
|
26
|
+
written(judgement);
|
|
27
|
+
const check = Effect.gen(function* () {
|
|
28
|
+
(yield* Asserted).judge(judgement);
|
|
29
|
+
});
|
|
30
|
+
branded.add(check);
|
|
31
|
+
return check;
|
|
32
|
+
};
|
|
33
|
+
const has = (table, key) => Object.hasOwn(table, key);
|
|
34
|
+
const isPlainObject = (value) => isObject(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
35
|
+
const isEmptyShape = (value) => isPlainObject(value) && Object.keys(value).length === 0;
|
|
36
|
+
/** A thunk that refuses with `text`: thrown when a matcher is called, or when a static is read. */
|
|
37
|
+
const refusing = (text) => () => {
|
|
38
|
+
throw refusalOf(text);
|
|
39
|
+
};
|
|
40
|
+
const forView = (view, negated) => ({
|
|
41
|
+
...view,
|
|
42
|
+
negated
|
|
43
|
+
});
|
|
44
|
+
const notView = (view) => forView(view, !view.negated);
|
|
45
|
+
const viewFor = (written, actual, message) => ({
|
|
46
|
+
actual,
|
|
47
|
+
message,
|
|
48
|
+
negated: false,
|
|
49
|
+
written
|
|
50
|
+
});
|
|
51
|
+
const messageOf = (argument) => typeof argument === "string" ? argument : void 0;
|
|
52
|
+
const refuseBooleanActual = (actual) => typeof actual === "boolean";
|
|
53
|
+
const refusedTextOf = (property) => has(refusedText, property) ? refusedText[property] : void 0;
|
|
54
|
+
const negatedTextOf = (property) => has(negatedText, property) ? negatedText[property] : void 0;
|
|
55
|
+
const textRefusalOf = (view, property) => view.negated ? negatedTextOf(property) : refusedTextOf(property);
|
|
56
|
+
const readRefusals = {
|
|
57
|
+
resolves: refusedText.resolves,
|
|
58
|
+
rejects: refusedText.rejects
|
|
59
|
+
};
|
|
60
|
+
const readRefusal = (property) => readRefusals[property];
|
|
61
|
+
const neededArity = {
|
|
62
|
+
toThrow: 1,
|
|
63
|
+
toThrowError: 1,
|
|
64
|
+
toSatisfy: 2,
|
|
65
|
+
toMatchObject: 1
|
|
66
|
+
};
|
|
67
|
+
const tooFewArguments = (property, args) => args.length < neededArity[property];
|
|
68
|
+
const vacuousMatchObject = (property, args) => property === "toMatchObject" && isEmptyShape(args[0]);
|
|
69
|
+
const missingArgument = (property, args) => tooFewArguments(property, args) || vacuousMatchObject(property, args);
|
|
70
|
+
const memberAt = (target, property) => Reflect.get(target, property, target);
|
|
71
|
+
const isCallable = (value) => typeof value === "function";
|
|
72
|
+
const invokeMember = (target, property, args) => {
|
|
73
|
+
const member = memberAt(target, property);
|
|
74
|
+
if (isCallable(member)) Reflect.apply(member, target, args);
|
|
75
|
+
};
|
|
76
|
+
const judgementOf = (view, property, args) => (make) => {
|
|
77
|
+
const assertion = make(view.actual, view.message);
|
|
78
|
+
const target = view.negated ? assertion.not : assertion;
|
|
79
|
+
invokeMember(target, property, args);
|
|
80
|
+
};
|
|
81
|
+
const judgedCheck = (view, property, args) => makeCheck(judgementOf(view, property, args), view.written);
|
|
82
|
+
const genericMember = (view, property) => (...args) => judgedCheck(view, property, args);
|
|
83
|
+
const neededMember = (view, property) => (...args) => {
|
|
84
|
+
if (missingArgument(property, args)) throw refusalOf(neededText[property]);
|
|
85
|
+
return judgedCheck(view, property, args);
|
|
86
|
+
};
|
|
87
|
+
const absent = { found: false };
|
|
88
|
+
const present = (value) => ({
|
|
89
|
+
found: true,
|
|
90
|
+
value
|
|
91
|
+
});
|
|
92
|
+
const valueOf = (member) => member.found ? member.value : void 0;
|
|
93
|
+
const fallbackMember = (view, property) => has(neededText, property) ? present(neededMember(view, property)) : present(genericMember(view, property));
|
|
94
|
+
const refusedMember = (view, property) => {
|
|
95
|
+
const text = textRefusalOf(view, property);
|
|
96
|
+
if (text === void 0) return absent;
|
|
97
|
+
return present(refusing(text));
|
|
98
|
+
};
|
|
99
|
+
const afterRefusal = (view, property) => {
|
|
100
|
+
const refused = refusedMember(view, property);
|
|
101
|
+
if (refused.found) return refused;
|
|
102
|
+
return fallbackMember(view, property);
|
|
103
|
+
};
|
|
104
|
+
const negationMember = (view, property) => property === "not" ? present(matcherView(notView(view))) : absent;
|
|
105
|
+
const viewMember = (view, property) => {
|
|
106
|
+
const negation = negationMember(view, property);
|
|
107
|
+
if (negation.found) return negation;
|
|
108
|
+
return afterRefusal(view, property);
|
|
109
|
+
};
|
|
110
|
+
const memberOf = (view, property) => {
|
|
111
|
+
const read = readRefusal(property);
|
|
112
|
+
if (read !== void 0) throw refusalOf(read);
|
|
113
|
+
return valueOf(viewMember(view, property));
|
|
114
|
+
};
|
|
115
|
+
const memberFor = (view, property) => typeof property === "string" ? memberOf(view, property) : void 0;
|
|
116
|
+
const viewHandler = (view) => ({ get: (_target, property) => memberFor(view, property) });
|
|
117
|
+
const matcherView = (view) => new Proxy({}, viewHandler(view));
|
|
118
|
+
const assertionView = (written, args) => {
|
|
119
|
+
if (refuseBooleanActual(args[0])) throw refusalOf(booleanRefusal);
|
|
120
|
+
return matcherView(viewFor(written, args[0], messageOf(args[1])));
|
|
121
|
+
};
|
|
122
|
+
const isDecodingSchema = (value) => Schema.isSchema(value);
|
|
123
|
+
const asMatcher = (value) => {
|
|
124
|
+
if (isObject(value) === false) throw new Error("vitest returned no asymmetric matcher");
|
|
125
|
+
return value;
|
|
126
|
+
};
|
|
127
|
+
const toStandardSchema = (schema) => isDecodingSchema(schema) ? Schema.toStandardSchemaV1(schema) : schema;
|
|
128
|
+
const standardSchemaOf = (schema) => asMatcher(V.expect.schemaMatching(toStandardSchema(schema)));
|
|
129
|
+
const notShapes = {
|
|
130
|
+
stringContaining: V.expect.not.stringContaining,
|
|
131
|
+
objectContaining: V.expect.not.objectContaining,
|
|
132
|
+
arrayContaining: V.expect.not.arrayContaining,
|
|
133
|
+
stringMatching: V.expect.not.stringMatching
|
|
134
|
+
};
|
|
135
|
+
const shapes = {
|
|
136
|
+
objectContaining: V.expect.objectContaining,
|
|
137
|
+
arrayContaining: V.expect.arrayContaining,
|
|
138
|
+
stringContaining: V.expect.stringContaining,
|
|
139
|
+
stringMatching: V.expect.stringMatching,
|
|
140
|
+
closeTo: V.expect.closeTo,
|
|
141
|
+
any: V.expect.any,
|
|
142
|
+
schemaMatching: standardSchemaOf,
|
|
143
|
+
not: notShapes,
|
|
144
|
+
anything: refusing(refusedText.anything),
|
|
145
|
+
poll: refusing(refusedText.poll),
|
|
146
|
+
soft: refusing(refusedText.soft)
|
|
147
|
+
};
|
|
148
|
+
const refusalGetters = [
|
|
149
|
+
["anything", refusedText.anything],
|
|
150
|
+
["poll", refusedText.poll],
|
|
151
|
+
["soft", refusedText.soft]
|
|
152
|
+
];
|
|
153
|
+
const defineRefusalGetters = (target) => {
|
|
154
|
+
for (const [name, text] of refusalGetters) Object.defineProperty(target, name, { get: refusing(text) });
|
|
155
|
+
};
|
|
156
|
+
const unreachableTarget = () => () => {
|
|
157
|
+
throw new Error("the expect proxy answers every call");
|
|
158
|
+
};
|
|
159
|
+
const expectHandler = (written) => ({ apply: (_target, _thisArgument, argumentList) => assertionView(written, argumentList) });
|
|
160
|
+
const expectFor = (written) => {
|
|
161
|
+
const base = Object.assign(unreachableTarget(), shapes);
|
|
162
|
+
defineRefusalGetters(base);
|
|
163
|
+
return new Proxy(base, expectHandler(written));
|
|
164
|
+
};
|
|
165
|
+
/** @internal */
|
|
166
|
+
const makeLedger = (ctx) => {
|
|
167
|
+
const pending = /* @__PURE__ */ new Set();
|
|
168
|
+
const counter = {
|
|
169
|
+
judged: 0,
|
|
170
|
+
since: 0
|
|
171
|
+
};
|
|
172
|
+
const hard = (actual, message) => ctx.expect(actual, message);
|
|
173
|
+
return {
|
|
174
|
+
asserted: {
|
|
175
|
+
judge: (judgement) => {
|
|
176
|
+
pending.delete(judgement);
|
|
177
|
+
counter.judged += 1;
|
|
178
|
+
counter.since += 1;
|
|
179
|
+
if (counter.since > 1) throw refusalOf(refusePiecewise);
|
|
180
|
+
authorize(() => judgement(hard));
|
|
181
|
+
},
|
|
182
|
+
step: () => {
|
|
183
|
+
counter.since = 0;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
written: (judgement) => {
|
|
187
|
+
pending.add(judgement);
|
|
188
|
+
},
|
|
189
|
+
unyielded: () => pending.size,
|
|
190
|
+
judged: () => counter.judged
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/** @internal */
|
|
194
|
+
const checksFor = (ledger) => ({ expect: expectFor(ledger.written) });
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/internal/test-context.ts
|
|
197
|
+
/** @internal */
|
|
198
|
+
const vitestTestContextKey = "@systemfsoftware/vitest/TestContext";
|
|
199
|
+
/**
|
|
200
|
+
* The running Vitest test, or `null` outside a run; provided on every test the fork runs.
|
|
201
|
+
*
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
const VitestTestContext = Context.Reference(vitestTestContextKey, { defaultValue: () => null });
|
|
205
|
+
//#endregion
|
|
206
|
+
export { isCheck as a, checksFor as i, vitestTestContextKey as n, makeLedger as o, Asserted as r, VitestTestContext as t };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/vitest",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://github.com/systemfsoftware/systemfsoftware/tree/main/packages/vitest#readme",
|
|
12
12
|
"bugs": "https://github.com/systemfsoftware/systemfsoftware/issues",
|
|
13
|
-
"description": "A fork of @effect/vitest whose defaults make the lazy test a good test: fresh layers, a second run that catches leaked state, virtual time,
|
|
13
|
+
"description": "A fork of @effect/vitest whose defaults make the lazy test a good test: expect bound to the test's own callback, one check per observed state, fresh layers, a second run that catches leaked state, virtual time, and properties refuted against a constant impostor.",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"effect",
|
|
16
16
|
"effect-ts",
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"default": "./dist/index.mjs"
|
|
27
27
|
},
|
|
28
|
-
"./
|
|
29
|
-
"types": "./dist/
|
|
30
|
-
"default": "./dist/
|
|
28
|
+
"./guard": {
|
|
29
|
+
"types": "./dist/guard.d.ts",
|
|
30
|
+
"default": "./dist/guard.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./integration": {
|
|
33
|
+
"types": "./dist/integration.d.ts",
|
|
34
|
+
"default": "./dist/integration.mjs"
|
|
31
35
|
},
|
|
32
36
|
"./TestClock": {
|
|
33
37
|
"types": "./dist/TestClock.d.ts",
|
|
34
38
|
"default": "./dist/TestClock.mjs"
|
|
35
39
|
},
|
|
36
|
-
"./utils": {
|
|
37
|
-
"types": "./dist/utils.d.ts",
|
|
38
|
-
"default": "./dist/utils.mjs"
|
|
39
|
-
},
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/internal/refusals.ts
|
|
3
|
-
/** @internal */
|
|
4
|
-
const refuseHook = "✗ hooks share state between tests. Build what a test needs inside it; services come fresh per test from layer(Service.layer)((it) => { ... }).";
|
|
5
|
-
/** @internal */
|
|
6
|
-
const refuseNoAssertion = "✗ this test ran no assertion, so it cannot fail. Assert on what the code returned: expect(actual).toEqual(expected).";
|
|
7
|
-
/** @internal */
|
|
8
|
-
const refuseAsync = "✗ an async test runs Effects outside the test runtime: no virtual time, no fresh services, no leak check. Return the Effect instead: it.effect(name, () => Effect.gen(function* () { ... })).";
|
|
9
|
-
/** @internal */
|
|
10
|
-
const refuseBareEffect = "✗ a bare test body that returns an Effect never runs it, so nothing in the test was checked. Register it on the Effect lane: it.effect(name, () => Effect.gen(function* () { ... })).";
|
|
11
|
-
/** @internal */
|
|
12
|
-
const refuseUnprovided = "✗ the test needs a service that nothing provides. Pipe the body through Effect.provide(Service.layer), or write the tests inside layer(Service.layer)((it) => { ... }); every test gets its own fresh build.";
|
|
13
|
-
/** @internal */
|
|
14
|
-
const refuseBoolean = "✗ expect(<boolean>) can only report 'expected false to be true'. Pass the two values instead: expect(Equal.equals(a, b)).toBe(true) becomes expect(a).toEqual(b). A predicate: expect(value).toSatisfy(predicate).";
|
|
15
|
-
/** @internal */
|
|
16
|
-
const refusePositionalProp = "✗ it.prop(name, [arbitraries], predicate) is removed. Name the function under test and pass a budget: it.prop(name, { of, subject, runs }, holds).";
|
|
17
|
-
/** @internal */
|
|
18
|
-
const presenceMessage = (name) => `✗ ${name} passes for almost any value the code returns. Assert the value: toEqual(expected); for a key that must exist: toHaveProperty(key).`;
|
|
19
|
-
/** @internal */
|
|
20
|
-
const narrowVacuous = [
|
|
21
|
-
"toBeDefined",
|
|
22
|
-
"toBeTruthy",
|
|
23
|
-
"toBeFalsy"
|
|
24
|
-
];
|
|
25
|
-
/** @internal */
|
|
26
|
-
const narrowNegated = [
|
|
27
|
-
...narrowVacuous,
|
|
28
|
-
"toBeNull",
|
|
29
|
-
"toBeUndefined"
|
|
30
|
-
];
|
|
31
|
-
//#endregion
|
|
32
|
-
export { refuseBareEffect as a, refuseNoAssertion as c, refuseAsync as i, refusePositionalProp as l, narrowVacuous as n, refuseBoolean as o, presenceMessage as r, refuseHook as s, narrowNegated as t, refuseUnprovided as u };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/internal/refusals.d.ts
|
|
3
|
-
/** @internal */
|
|
4
|
-
declare const refuseHook = "✗ hooks share state between tests. Build what a test needs inside it; services come fresh per test from layer(Service.layer)((it) => { ... }).";
|
|
5
|
-
/** @internal */
|
|
6
|
-
declare const refuseNoAssertion = "✗ this test ran no assertion, so it cannot fail. Assert on what the code returned: expect(actual).toEqual(expected).";
|
|
7
|
-
/** @internal */
|
|
8
|
-
declare const refuseAsync = "✗ an async test runs Effects outside the test runtime: no virtual time, no fresh services, no leak check. Return the Effect instead: it.effect(name, () => Effect.gen(function* () { ... })).";
|
|
9
|
-
/** @internal */
|
|
10
|
-
declare const refuseBareEffect = "✗ a bare test body that returns an Effect never runs it, so nothing in the test was checked. Register it on the Effect lane: it.effect(name, () => Effect.gen(function* () { ... })).";
|
|
11
|
-
/** @internal */
|
|
12
|
-
declare const refuseUnprovided = "✗ the test needs a service that nothing provides. Pipe the body through Effect.provide(Service.layer), or write the tests inside layer(Service.layer)((it) => { ... }); every test gets its own fresh build.";
|
|
13
|
-
/** @internal */
|
|
14
|
-
declare const refuseBoolean = "✗ expect(<boolean>) can only report 'expected false to be true'. Pass the two values instead: expect(Equal.equals(a, b)).toBe(true) becomes expect(a).toEqual(b). A predicate: expect(value).toSatisfy(predicate).";
|
|
15
|
-
/** @internal */
|
|
16
|
-
declare const refusePositionalProp = "✗ it.prop(name, [arbitraries], predicate) is removed. Name the function under test and pass a budget: it.prop(name, { of, subject, runs }, holds).";
|
|
17
|
-
/** @internal */
|
|
18
|
-
type PresenceMessage<N extends string = string> = `✗ ${N} passes for almost any value the code returns. Assert the value: toEqual(expected); for a key that must exist: toHaveProperty(key).`;
|
|
19
|
-
/**
|
|
20
|
-
* The narrowed matcher as the type sees it: a call whose `this` is not the assertion cannot compile, and the
|
|
21
|
-
* refused text is the compiler error (KTD9). The run time throws the same text.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
type PresenceRefusal<N extends string = string> = (this: PresenceMessage<N>, ...args: Array<never>) => void;
|
|
26
|
-
/** @internal */
|
|
27
|
-
declare const presenceMessage: <N extends string>(name: N) => PresenceMessage<N>;
|
|
28
|
-
/** @internal */
|
|
29
|
-
declare const narrowVacuous: readonly ['toBeDefined', 'toBeTruthy', 'toBeFalsy'];
|
|
30
|
-
/** @internal */
|
|
31
|
-
type NarrowVacuousName = (typeof narrowVacuous)[number];
|
|
32
|
-
/** @internal */
|
|
33
|
-
declare const narrowNegated: readonly ["toBeDefined", "toBeTruthy", "toBeFalsy", "toBeNull", "toBeUndefined"];
|
|
34
|
-
/** @internal */
|
|
35
|
-
type NarrowNegatedName = (typeof narrowNegated)[number];
|
|
36
|
-
//#endregion
|
|
37
|
-
export { narrowVacuous as a, refuseBareEffect as c, refuseNoAssertion as d, refusePositionalProp as f, narrowNegated as i, refuseBoolean as l, NarrowVacuousName as n, presenceMessage as o, refuseUnprovided as p, PresenceRefusal as r, refuseAsync as s, NarrowNegatedName as t, refuseHook as u };
|
package/dist/refusals.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as narrowVacuous, c as refuseBareEffect, d as refuseNoAssertion, f as refusePositionalProp, i as narrowNegated, l as refuseBoolean, o as presenceMessage, p as refuseUnprovided, s as refuseAsync, u as refuseHook } from "./refusals-_6e3GzVK.js";
|
|
3
|
-
export { narrowNegated, narrowVacuous, presenceMessage, refuseAsync, refuseBareEffect, refuseBoolean, refuseHook, refuseNoAssertion, refusePositionalProp, refuseUnprovided };
|
package/dist/refusals.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { a as refuseBareEffect, c as refuseNoAssertion, i as refuseAsync, l as refusePositionalProp, n as narrowVacuous, o as refuseBoolean, r as presenceMessage, s as refuseHook, t as narrowNegated, u as refuseUnprovided } from "./refusals-BQtDszyU.mjs";
|
|
3
|
-
export { narrowNegated, narrowVacuous, presenceMessage, refuseAsync, refuseBareEffect, refuseBoolean, refuseHook, refuseNoAssertion, refusePositionalProp, refuseUnprovided };
|
package/dist/utils.d.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import * as Cause from "effect/Cause";
|
|
3
|
-
import * as Exit from "effect/Exit";
|
|
4
|
-
import * as Option from "effect/Option";
|
|
5
|
-
import * as Result from "effect/Result";
|
|
6
|
-
//#region src/utils.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Inspects the value a thunk threw. `A` defaults to `unknown` so a caller passes any inspection function.
|
|
9
|
-
*/
|
|
10
|
-
type ThrownValidator = <A = unknown>(thrown: A) => undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Any class, abstract ones included: what `assertInstanceOf` accepts and what `instanceof` takes.
|
|
13
|
-
*/
|
|
14
|
-
type AnyConstructor = abstract new (...args: never[]) => object;
|
|
15
|
-
/**
|
|
16
|
-
* Fails the current test with the provided error message.
|
|
17
|
-
*
|
|
18
|
-
* @since 4.0.0
|
|
19
|
-
*/
|
|
20
|
-
export declare function fail(message: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Asserts that `actual` is deeply strictly equal to `expected`.
|
|
23
|
-
*
|
|
24
|
-
* @since 4.0.0
|
|
25
|
-
*/
|
|
26
|
-
export declare const deepStrictEqual: {
|
|
27
|
-
<A>(actual: A, expected: A, message?: undefined): void;
|
|
28
|
-
<A>(expected: A, message?: undefined): (actual: A) => void;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Asserts that `actual` is not deeply strictly equal to `expected`.
|
|
32
|
-
*
|
|
33
|
-
* Chai names the negation of its deep comparison `notDeepEqual`; there, `deepStrictEqual` and `deepEqual` are
|
|
34
|
-
* one function.
|
|
35
|
-
*
|
|
36
|
-
* @since 4.0.0
|
|
37
|
-
*/
|
|
38
|
-
export declare const notDeepStrictEqual: {
|
|
39
|
-
<A>(actual: A, expected: A, message?: undefined): void;
|
|
40
|
-
<A>(expected: A, message?: undefined): (actual: A) => void;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Asserts that `actual` is strictly equal to `expected`.
|
|
44
|
-
*
|
|
45
|
-
* @since 4.0.0
|
|
46
|
-
*/
|
|
47
|
-
export declare const strictEqual: {
|
|
48
|
-
<A>(actual: A, expected: A, message?: undefined): void;
|
|
49
|
-
<A>(expected: A, message?: undefined): (actual: A) => void;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Asserts that `actual` is equal to `expected` using the `Equal.equals` trait.
|
|
53
|
-
*
|
|
54
|
-
* @since 4.0.0
|
|
55
|
-
*/
|
|
56
|
-
export declare const assertEquals: {
|
|
57
|
-
<A>(actual: A, expected: A, message?: undefined): void;
|
|
58
|
-
<A>(expected: A, message?: undefined): (actual: A) => void;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Asserts that `thunk` does not throw an error.
|
|
62
|
-
*
|
|
63
|
-
* @since 4.0.0
|
|
64
|
-
*/
|
|
65
|
-
export declare const doesNotThrow: {
|
|
66
|
-
(thunk: () => void, message?: string): void;
|
|
67
|
-
(message?: string): (thunk: () => void) => void;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Asserts that `value` is an instance of `constructor`.
|
|
71
|
-
*
|
|
72
|
-
* @since 4.0.0
|
|
73
|
-
*/
|
|
74
|
-
export declare const assertInstanceOf: {
|
|
75
|
-
<C extends AnyConstructor>(value: unknown, ctor: C, message?: string): asserts value is InstanceType<C>;
|
|
76
|
-
<C extends AnyConstructor>(ctor: C, message?: string): (value: unknown) => asserts value is InstanceType<C>;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Asserts that `self` is `true`.
|
|
80
|
-
*
|
|
81
|
-
* @since 4.0.0
|
|
82
|
-
*/
|
|
83
|
-
export declare const assertTrue: {
|
|
84
|
-
(self: boolean, message?: string): asserts self;
|
|
85
|
-
(message?: string): (self: boolean) => asserts self;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Asserts that `self` is `false`.
|
|
89
|
-
*
|
|
90
|
-
* @since 4.0.0
|
|
91
|
-
*/
|
|
92
|
-
export declare const assertFalse: {
|
|
93
|
-
(self: boolean, message?: string): void;
|
|
94
|
-
(message?: string): (self: boolean) => void;
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Asserts that `actual` includes `expected`.
|
|
98
|
-
*
|
|
99
|
-
* @since 4.0.0
|
|
100
|
-
*/
|
|
101
|
-
export declare const assertInclude: {
|
|
102
|
-
(actual: string | undefined, expected: string): void;
|
|
103
|
-
(expected: string): (actual: string | undefined) => void;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Asserts that `actual` matches `regExp`.
|
|
107
|
-
*
|
|
108
|
-
* @since 4.0.0
|
|
109
|
-
*/
|
|
110
|
-
export declare const assertMatch: {
|
|
111
|
-
(actual: string, regExp: RegExp): void;
|
|
112
|
-
(regExp: RegExp): (actual: string) => void;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Asserts that `thunk` throws, optionally checking the thrown value against an expected `Error` or validation
|
|
116
|
-
* function.
|
|
117
|
-
*
|
|
118
|
-
* @since 4.0.0
|
|
119
|
-
*/
|
|
120
|
-
export declare const throws: {
|
|
121
|
-
(thunk: () => void, error?: Error | ThrownValidator): void;
|
|
122
|
-
(error?: Error | ThrownValidator): (thunk: () => void) => void;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Asserts that `thunk` throws or returns a rejected promise, optionally checking the failure value against an
|
|
126
|
-
* expected `Error` or validation function.
|
|
127
|
-
*
|
|
128
|
-
* @since 4.0.0
|
|
129
|
-
*/
|
|
130
|
-
export declare const throwsAsync: {
|
|
131
|
-
(thunk: () => Promise<void>, error?: Error | ThrownValidator): Promise<void>;
|
|
132
|
-
(error?: Error | ThrownValidator): (thunk: () => Promise<void>) => Promise<void>;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Asserts that `option` is `None`.
|
|
136
|
-
*
|
|
137
|
-
* @since 4.0.0
|
|
138
|
-
*/
|
|
139
|
-
export declare function assertNone<A>(option: Option.Option<A>): asserts option is Option.None<never>;
|
|
140
|
-
/**
|
|
141
|
-
* Asserts that `a` is not `undefined`.
|
|
142
|
-
*
|
|
143
|
-
* @since 4.0.0
|
|
144
|
-
*/
|
|
145
|
-
export declare function assertDefined<A>(a: A | undefined): asserts a is Exclude<A, undefined>;
|
|
146
|
-
/**
|
|
147
|
-
* Asserts that `a` is `undefined`.
|
|
148
|
-
*
|
|
149
|
-
* @since 4.0.0
|
|
150
|
-
*/
|
|
151
|
-
export declare function assertUndefined<A>(a: A | undefined): asserts a is undefined;
|
|
152
|
-
/**
|
|
153
|
-
* Asserts that `option` is `Some` and contains a value equal to `expected`.
|
|
154
|
-
*
|
|
155
|
-
* @since 4.0.0
|
|
156
|
-
*/
|
|
157
|
-
export declare const assertSome: {
|
|
158
|
-
<A>(option: Option.Option<A>, expected: A): asserts option is Option.Some<A>;
|
|
159
|
-
<A>(expected: A): (option: Option.Option<A>) => asserts option is Option.Some<A>;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Asserts that `result` is `Success` and contains a value equal to `expected`.
|
|
163
|
-
*
|
|
164
|
-
* @since 4.0.0
|
|
165
|
-
*/
|
|
166
|
-
export declare const assertSuccess: {
|
|
167
|
-
<A, E>(result: Result.Result<A, E>, expected: A): asserts result is Result.Success<A, never>;
|
|
168
|
-
<A, E>(expected: A): (result: Result.Result<A, E>) => asserts result is Result.Success<A, never>;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Asserts that `result` is `Failure` and contains an error equal to `expected`.
|
|
172
|
-
*
|
|
173
|
-
* @since 4.0.0
|
|
174
|
-
*/
|
|
175
|
-
export declare const assertFailure: {
|
|
176
|
-
<A, E>(result: Result.Result<A, E>, expected: E): asserts result is Result.Failure<never, E>;
|
|
177
|
-
<A, E>(expected: E): (result: Result.Result<A, E>) => asserts result is Result.Failure<never, E>;
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Asserts that `exit` is a failure with a cause equal to `expected`.
|
|
181
|
-
*
|
|
182
|
-
* @since 4.0.0
|
|
183
|
-
*/
|
|
184
|
-
export declare const assertExitFailure: {
|
|
185
|
-
<A, E>(exit: Exit.Exit<A, E>, expected: Cause.Cause<E>): asserts exit is Exit.Failure<never, E>;
|
|
186
|
-
<A, E>(expected: Cause.Cause<E>): (exit: Exit.Exit<A, E>) => asserts exit is Exit.Failure<never, E>;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Asserts that `exit` is a success with a value equal to `expected`.
|
|
190
|
-
*
|
|
191
|
-
* @since 4.0.0
|
|
192
|
-
*/
|
|
193
|
-
export declare const assertExitSuccess: {
|
|
194
|
-
<A, E>(exit: Exit.Exit<A, E>, expected: A): asserts exit is Exit.Success<A, never>;
|
|
195
|
-
<A, E>(expected: A): (exit: Exit.Exit<A, E>) => asserts exit is Exit.Success<A, never>;
|
|
196
|
-
};
|
|
197
|
-
//#endregion
|