@effect/vitest 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Effectful Technologies Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Effect
2
+
3
+ Welcome to Effect, a powerful TypeScript framework that provides a fully-fledged functional effect system with a rich standard library.
4
+
5
+ # Requirements
6
+
7
+ - TypeScript 5.0 or newer
8
+ - The `strict` flag enabled in your `tsconfig.json` file
9
+
10
+ ```
11
+ {
12
+ // ...
13
+ "compilerOptions": {
14
+ // ...
15
+ "strict": true,
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Documentation
21
+
22
+ For detailed information and usage examples, please visit the [Effect website](https://www.effect.website/).
23
+
24
+ ## Introduction to Effect
25
+
26
+ To get started with Effect, watch our introductory video on YouTube. This video provides an overview of Effect and its key features, making it a great starting point for newcomers:
27
+
28
+ [![Introduction to Effect](https://img.youtube.com/vi/SloZE4i4Zfk/maxresdefault.jpg)](https://youtu.be/SloZE4i4Zfk)
29
+
30
+ ## Connect with Our Community
31
+
32
+ Join our vibrant community on Discord to interact with fellow developers, ask questions, and share your experiences. Here's the invite link to our Discord server: [Join Effect's Discord Community](https://discord.gg/hdt7t7jpvn).
33
+
34
+ ## API Reference
35
+
36
+ For detailed information on the Effect API, please refer to our [API Reference](https://effect-ts.github.io/effect/).
37
+
38
+ ## Pull Requests
39
+
40
+ We welcome contributions via pull requests! Here are some guidelines to help you get started:
41
+
42
+ 1. Fork the repository and clone it to your local machine.
43
+ 2. Create a new branch for your changes: `git checkout -b my-new-feature`.
44
+ 3. Ensure you have the required dependencies installed by running: `pnpm install` (assuming pnpm version `8.x`).
45
+ 4. Make your desired changes and, if applicable, include tests to validate your modifications.
46
+ 5. Run the following commands to ensure the integrity of your changes:
47
+ - `pnpm check`: Verify that the code compiles.
48
+ - `pnpm test`: Execute the tests.
49
+ - `pnpm circular`: Confirm there are no circular imports.
50
+ - `pnpm lint`: Check for code style adherence (if you happen to encounter any errors during this process, you can use `pnpm lint-fix` to automatically fix some of these style issues).
51
+ - `pnpm dtslint`: Run type-level tests.
52
+ - `pnpm docgen`: Update the automatically generated documentation.
53
+ 6. Create a changeset for your changes: before committing your changes, create a changeset to document the modifications. This helps in tracking and communicating the changes effectively. To create a changeset, run the following command: `pnpm changeset`. Always choose the `patch` option when prompted (please note that we are currently in pre-release mode).
54
+ 7. Commit your changes: after creating the changeset, commit your changes with a descriptive commit message: `git commit -am 'Add some feature'`.
55
+ 8. Push your changes to your fork: `git push origin my-new-feature`.
56
+ 9. Open a pull request against our `main` branch.
57
+
58
+ ### Pull Request Guidelines
59
+
60
+ - Please make sure your changes are consistent with the project's existing style and conventions.
61
+ - Please write clear commit messages and include a summary of your changes in the pull request description.
62
+ - Please make sure all tests pass and add new tests as necessary.
63
+ - If your change requires documentation, please update the relevant documentation.
64
+ - Please be patient! We will do our best to review your pull request as soon as possible.
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.scopedLive = exports.scoped = exports.live = exports.it = exports.flakyTest = exports.effect = void 0;
7
+ var Duration = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Duration"));
8
+ var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Effect"));
9
+ var _Function = /*#__PURE__*/require("effect/Function");
10
+ var Layer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Layer"));
11
+ var Logger = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Logger"));
12
+ var Schedule = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/Schedule"));
13
+ var TestEnvironment = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("effect/TestContext"));
14
+ var V = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("vitest"));
15
+ function _getRequireWildcardCache(e) {
16
+ if ("function" != typeof WeakMap) return null;
17
+ var r = new WeakMap(),
18
+ t = new WeakMap();
19
+ return (_getRequireWildcardCache = function (e) {
20
+ return e ? t : r;
21
+ })(e);
22
+ }
23
+ function _interopRequireWildcard(e, r) {
24
+ if (!r && e && e.__esModule) return e;
25
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
26
+ default: e
27
+ };
28
+ var t = _getRequireWildcardCache(r);
29
+ if (t && t.has(e)) return t.get(e);
30
+ var n = {
31
+ __proto__: null
32
+ },
33
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
34
+ for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) {
35
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
36
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
37
+ }
38
+ return n.default = e, t && t.set(e, n), n;
39
+ }
40
+ /**
41
+ * @since 1.0.0
42
+ */
43
+
44
+ /**
45
+ * @since 1.0.0
46
+ */
47
+ const it = exports.it = V.it;
48
+ const TestEnv = /*#__PURE__*/TestEnvironment.TestContext.pipe( /*#__PURE__*/Layer.provide( /*#__PURE__*/Logger.remove(Logger.defaultLogger)));
49
+ /**
50
+ * @since 1.0.0
51
+ */
52
+ const effect = exports.effect = /*#__PURE__*/(() => {
53
+ const f = (name, self, timeout = 5000) => it(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout);
54
+ return Object.assign(f, {
55
+ skip: (name, self, timeout = 5000) => it.skip(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout),
56
+ only: (name, self, timeout = 5000) => it.only(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout)
57
+ });
58
+ })();
59
+ /**
60
+ * @since 1.0.0
61
+ */
62
+ const live = (name, self, timeout = 5000) => it(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.runPromise), timeout);
63
+ /**
64
+ * @since 1.0.0
65
+ */
66
+ exports.live = live;
67
+ const flakyTest = (self, timeout = Duration.seconds(30)) => (0, _Function.pipe)(Effect.catchAllDefect(self, Effect.fail), Effect.retry((0, _Function.pipe)(Schedule.recurs(10), Schedule.compose(Schedule.elapsed), Schedule.whileOutput(Duration.lessThanOrEqualTo(timeout)))), Effect.orDie);
68
+ /**
69
+ * @since 1.0.0
70
+ */
71
+ exports.flakyTest = flakyTest;
72
+ const scoped = (name, self, timeout = 5000) => it(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.scoped, Effect.provide(TestEnv), Effect.runPromise), timeout);
73
+ /**
74
+ * @since 1.0.0
75
+ */
76
+ exports.scoped = scoped;
77
+ const scopedLive = (name, self, timeout = 5000) => it(name, () => (0, _Function.pipe)(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.scoped, Effect.runPromise), timeout);
78
+ exports.scopedLive = scopedLive;
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Duration","_interopRequireWildcard","require","Effect","_Function","Layer","Logger","Schedule","TestEnvironment","V","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","it","exports","TestEnv","TestContext","pipe","provide","remove","defaultLogger","effect","f","name","self","timeout","isEffect","suspend","runPromise","assign","skip","only","live","flakyTest","seconds","catchAllDefect","fail","retry","recurs","compose","elapsed","whileOutput","lessThanOrEqualTo","orDie","scoped","scopedLive"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;AAGA,IAAAA,QAAA,gBAAAC,uBAAA,eAAAC,OAAA;AACA,IAAAC,MAAA,gBAAAF,uBAAA,eAAAC,OAAA;AACA,IAAAE,SAAA,gBAAAF,OAAA;AACA,IAAAG,KAAA,gBAAAJ,uBAAA,eAAAC,OAAA;AACA,IAAAI,MAAA,gBAAAL,uBAAA,eAAAC,OAAA;AACA,IAAAK,QAAA,gBAAAN,uBAAA,eAAAC,OAAA;AAEA,IAAAM,eAAA,gBAAAP,uBAAA,eAAAC,OAAA;AAGA,IAAAO,CAAA,gBAAAR,uBAAA,eAAAC,OAAA;AAA2B,SAAAQ,yBAAAC,CAAA;EAAA,yBAAAC,OAAA;EAAA,IAAAC,CAAA,OAAAD,OAAA;IAAAE,CAAA,OAAAF,OAAA;EAAA,QAAAF,wBAAA,YAAAA,CAAAC,CAAA;IAAA,OAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA;EAAA,GAAAF,CAAA;AAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA;EAAA,KAAAA,CAAA,I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EH;;;AAAAX,OAAA,CAAA8B,MAAA,GAAAA,MAAA;AAGO,MAAMC,UAAU,GAAGA,CACxBtB,IAAY,EACZC,IAE4C,EAC5CC,OAAO,GAAG,IAAK,KAEfZ,EAAE,CACAU,IAAI,EACJ,MACE,IAAArC,SAAA,CAAA+B,IAAI,EACFhC,MAAM,CAACyC,QAAQ,CAACF,IAAI,CAAC,GAAGA,IAAI,GAAGvC,MAAM,CAAC0C,OAAO,CAACH,IAAI,CAAC,EACnDvC,MAAM,CAAC2D,MAAM,EACb3D,MAAM,CAAC2C,UAAU,CAClB,EACHH,OAAO,CACR;AAAAX,OAAA,CAAA+B,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Duration from "effect/Duration";
5
+ import * as Effect from "effect/Effect";
6
+ import type * as Scope from "effect/Scope";
7
+ import type * as TestServices from "effect/TestServices";
8
+ import type { TestAPI } from "vitest";
9
+ import * as V from "vitest";
10
+ /**
11
+ * @since 1.0.0
12
+ */
13
+ export type API = TestAPI<{}>;
14
+ /**
15
+ * @since 1.0.0
16
+ */
17
+ export declare const it: API;
18
+ /**
19
+ * @since 1.0.0
20
+ */
21
+ export declare const effect: (<E, A>(name: string, self: Effect.Effect<A, E, TestServices.TestServices> | (() => Effect.Effect<A, E, TestServices.TestServices>), timeout?: number | V.TestOptions) => void) & {
22
+ skip: <E_1, A_1>(name: string, self: Effect.Effect<A_1, E_1, TestServices.TestServices> | (() => Effect.Effect<A_1, E_1, TestServices.TestServices>), timeout?: number) => void;
23
+ only: <E_2, A_2>(name: string, self: Effect.Effect<A_2, E_2, TestServices.TestServices> | (() => Effect.Effect<A_2, E_2, TestServices.TestServices>), timeout?: number) => void;
24
+ };
25
+ /**
26
+ * @since 1.0.0
27
+ */
28
+ export declare const live: <E, A>(name: string, self: Effect.Effect<A, E, never> | (() => Effect.Effect<A, E, never>), timeout?: number) => void;
29
+ /**
30
+ * @since 1.0.0
31
+ */
32
+ export declare const flakyTest: <A, E, R>(self: Effect.Effect<A, E, R>, timeout?: Duration.Duration) => Effect.Effect<A, never, R>;
33
+ /**
34
+ * @since 1.0.0
35
+ */
36
+ export declare const scoped: <E, A>(name: string, self: Effect.Effect<A, E, TestServices.TestServices | Scope.Scope> | (() => Effect.Effect<A, E, TestServices.TestServices | Scope.Scope>), timeout?: number) => void;
37
+ /**
38
+ * @since 1.0.0
39
+ */
40
+ export declare const scopedLive: <E, A>(name: string, self: Effect.Effect<A, E, Scope.Scope> | (() => Effect.Effect<A, E, Scope.Scope>), timeout?: number) => void;
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAA;AAE3B;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,EAAE,CAAC,CAAA;AAE7B;;GAEG;AACH,eAAO,MAAM,EAAE,EAAE,GAAU,CAAA;AAM3B;;GAEG;AACH,eAAO,MAAM,MAAM,gBAET,MAAM,2HAEH,MAAM,GAAG,EAAE,WAAW;2BAcvB,MAAM;2BAeN,MAAM;CAed,CAAA;AAEJ;;GAEG;AACH,eAAO,MAAM,IAAI,eACT,MAAM,kGAYX,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,oDAEX,iBAAiB,+BAYzB,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,eACX,MAAM,sKAgBX,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,eACf,MAAM,8GAeX,CAAA"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Duration from "effect/Duration";
5
+ import * as Effect from "effect/Effect";
6
+ import { pipe } from "effect/Function";
7
+ import * as Layer from "effect/Layer";
8
+ import * as Logger from "effect/Logger";
9
+ import * as Schedule from "effect/Schedule";
10
+ import * as TestEnvironment from "effect/TestContext";
11
+ import * as V from "vitest";
12
+ /**
13
+ * @since 1.0.0
14
+ */
15
+ export const it = V.it;
16
+ const TestEnv = /*#__PURE__*/TestEnvironment.TestContext.pipe( /*#__PURE__*/Layer.provide( /*#__PURE__*/Logger.remove(Logger.defaultLogger)));
17
+ /**
18
+ * @since 1.0.0
19
+ */
20
+ export const effect = /*#__PURE__*/(() => {
21
+ const f = (name, self, timeout = 5000) => it(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout);
22
+ return Object.assign(f, {
23
+ skip: (name, self, timeout = 5000) => it.skip(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout),
24
+ only: (name, self, timeout = 5000) => it.only(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.provide(TestEnv), Effect.runPromise), timeout)
25
+ });
26
+ })();
27
+ /**
28
+ * @since 1.0.0
29
+ */
30
+ export const live = (name, self, timeout = 5000) => it(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.runPromise), timeout);
31
+ /**
32
+ * @since 1.0.0
33
+ */
34
+ export const flakyTest = (self, timeout = Duration.seconds(30)) => pipe(Effect.catchAllDefect(self, Effect.fail), Effect.retry(pipe(Schedule.recurs(10), Schedule.compose(Schedule.elapsed), Schedule.whileOutput(Duration.lessThanOrEqualTo(timeout)))), Effect.orDie);
35
+ /**
36
+ * @since 1.0.0
37
+ */
38
+ export const scoped = (name, self, timeout = 5000) => it(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.scoped, Effect.provide(TestEnv), Effect.runPromise), timeout);
39
+ /**
40
+ * @since 1.0.0
41
+ */
42
+ export const scopedLive = (name, self, timeout = 5000) => it(name, () => pipe(Effect.isEffect(self) ? self : Effect.suspend(self), Effect.scoped, Effect.runPromise), timeout);
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Duration","Effect","pipe","Layer","Logger","Schedule","TestEnvironment","V","it","TestEnv","TestContext","provide","remove","defaultLogger","effect","f","name","self","timeout","isEffect","suspend","runPromise","Object","assign","skip","only","live","flakyTest","seconds","catchAllDefect","fail","retry","recurs","compose","elapsed","whileOutput","lessThanOrEqualTo","orDie","scoped","scopedLive"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,IAAI,QAAQ,iBAAiB;AACtC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAE3C,OAAO,KAAKC,eAAe,MAAM,oBAAoB;AAGrD,OAAO,KAAKC,CAAC,MAAM,QAAQ;AAO3B;;;AAGA,OAAO,MAAMC,EAAE,GAAQD,CAAC,CAACC,EAAE;AAE3B,MAAMC,OAAO,gBAAGH,eAAe,CAACI,WAAW,CAACR,IAAI,eAC9CC,KAAK,CAACQ,OAAO,eAACP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,aAAa,CAAC,CAAC,CACnD;AAED;;;AAGA,OAAO,MAAMC,MAAM,gBAAG,CAAC,MAAK;EAC1B,MAAMC,CAAC,GAAGA,CACRC,IAAY,EACZC,IAA6G,EAC7GC,OAAA,GAAkC,IAAK,KAEvCV,EAAE,CACAQ,IAAI,EACJ,MACEd,IAAI,CACFD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ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@effect/vitest",
3
+ "version": "0.1.0",
4
+ "description": "Set of helpers for testing Effect's with vitest",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/effect-ts/effect.git",
9
+ "directory": "packages/vitest"
10
+ },
11
+ "sideEffects": [],
12
+ "peerDependencies": {
13
+ "vitest": "^1.4.0",
14
+ "effect": "^2.4.10"
15
+ },
16
+ "main": "./dist/cjs/index.js",
17
+ "module": "./dist/esm/index.js",
18
+ "types": "./dist/dts/index.d.ts",
19
+ "exports": {
20
+ "./package.json": "./package.json",
21
+ ".": {
22
+ "types": "./dist/dts/index.d.ts",
23
+ "import": "./dist/esm/index.js",
24
+ "default": "./dist/cjs/index.js"
25
+ }
26
+ }
27
+ }
package/src/index.ts ADDED
@@ -0,0 +1,161 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Duration from "effect/Duration"
5
+ import * as Effect from "effect/Effect"
6
+ import { pipe } from "effect/Function"
7
+ import * as Layer from "effect/Layer"
8
+ import * as Logger from "effect/Logger"
9
+ import * as Schedule from "effect/Schedule"
10
+ import type * as Scope from "effect/Scope"
11
+ import * as TestEnvironment from "effect/TestContext"
12
+ import type * as TestServices from "effect/TestServices"
13
+ import type { TestAPI } from "vitest"
14
+ import * as V from "vitest"
15
+
16
+ /**
17
+ * @since 1.0.0
18
+ */
19
+ export type API = TestAPI<{}>
20
+
21
+ /**
22
+ * @since 1.0.0
23
+ */
24
+ export const it: API = V.it
25
+
26
+ const TestEnv = TestEnvironment.TestContext.pipe(
27
+ Layer.provide(Logger.remove(Logger.defaultLogger))
28
+ )
29
+
30
+ /**
31
+ * @since 1.0.0
32
+ */
33
+ export const effect = (() => {
34
+ const f = <E, A>(
35
+ name: string,
36
+ self: Effect.Effect<A, E, TestServices.TestServices> | (() => Effect.Effect<A, E, TestServices.TestServices>),
37
+ timeout: number | V.TestOptions = 5_000
38
+ ) =>
39
+ it(
40
+ name,
41
+ () =>
42
+ pipe(
43
+ Effect.isEffect(self) ? self : Effect.suspend(self),
44
+ Effect.provide(TestEnv),
45
+ Effect.runPromise
46
+ ),
47
+ timeout
48
+ )
49
+ return Object.assign(f, {
50
+ skip: <E, A>(
51
+ name: string,
52
+ self: Effect.Effect<A, E, TestServices.TestServices> | (() => Effect.Effect<A, E, TestServices.TestServices>),
53
+ timeout = 5_000
54
+ ) =>
55
+ it.skip(
56
+ name,
57
+ () =>
58
+ pipe(
59
+ Effect.isEffect(self) ? self : Effect.suspend(self),
60
+ Effect.provide(TestEnv),
61
+ Effect.runPromise
62
+ ),
63
+ timeout
64
+ ),
65
+ only: <E, A>(
66
+ name: string,
67
+ self: Effect.Effect<A, E, TestServices.TestServices> | (() => Effect.Effect<A, E, TestServices.TestServices>),
68
+ timeout = 5_000
69
+ ) =>
70
+ it.only(
71
+ name,
72
+ () =>
73
+ pipe(
74
+ Effect.isEffect(self) ? self : Effect.suspend(self),
75
+ Effect.provide(TestEnv),
76
+ Effect.runPromise
77
+ ),
78
+ timeout
79
+ )
80
+ })
81
+ })()
82
+
83
+ /**
84
+ * @since 1.0.0
85
+ */
86
+ export const live = <E, A>(
87
+ name: string,
88
+ self: Effect.Effect<A, E> | (() => Effect.Effect<A, E>),
89
+ timeout = 5_000
90
+ ) =>
91
+ it(
92
+ name,
93
+ () =>
94
+ pipe(
95
+ Effect.isEffect(self) ? self : Effect.suspend(self),
96
+ Effect.runPromise
97
+ ),
98
+ timeout
99
+ )
100
+
101
+ /**
102
+ * @since 1.0.0
103
+ */
104
+ export const flakyTest = <A, E, R>(
105
+ self: Effect.Effect<A, E, R>,
106
+ timeout: Duration.Duration = Duration.seconds(30)
107
+ ) =>
108
+ pipe(
109
+ Effect.catchAllDefect(self, Effect.fail),
110
+ Effect.retry(
111
+ pipe(
112
+ Schedule.recurs(10),
113
+ Schedule.compose(Schedule.elapsed),
114
+ Schedule.whileOutput(Duration.lessThanOrEqualTo(timeout))
115
+ )
116
+ ),
117
+ Effect.orDie
118
+ )
119
+
120
+ /**
121
+ * @since 1.0.0
122
+ */
123
+ export const scoped = <E, A>(
124
+ name: string,
125
+ self:
126
+ | Effect.Effect<A, E, Scope.Scope | TestServices.TestServices>
127
+ | (() => Effect.Effect<A, E, Scope.Scope | TestServices.TestServices>),
128
+ timeout = 5_000
129
+ ) =>
130
+ it(
131
+ name,
132
+ () =>
133
+ pipe(
134
+ Effect.isEffect(self) ? self : Effect.suspend(self),
135
+ Effect.scoped,
136
+ Effect.provide(TestEnv),
137
+ Effect.runPromise
138
+ ),
139
+ timeout
140
+ )
141
+
142
+ /**
143
+ * @since 1.0.0
144
+ */
145
+ export const scopedLive = <E, A>(
146
+ name: string,
147
+ self:
148
+ | Effect.Effect<A, E, Scope.Scope>
149
+ | (() => Effect.Effect<A, E, Scope.Scope>),
150
+ timeout = 5_000
151
+ ) =>
152
+ it(
153
+ name,
154
+ () =>
155
+ pipe(
156
+ Effect.isEffect(self) ? self : Effect.suspend(self),
157
+ Effect.scoped,
158
+ Effect.runPromise
159
+ ),
160
+ timeout
161
+ )