@usestrider/vitest 0.0.0-stage → 0.1.1

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/INDEX.md ADDED
@@ -0,0 +1,13 @@
1
+ # @usestrider/vitest API index
2
+
3
+ Generated from `src/` by `pnpm index`; don't edit by hand. One line per declaration and member, by entry point, module and `@category`. Experimental APIs are marked. The browsable reference is generated from the same sources by `pnpm api-reference`.
4
+
5
+ ## `@usestrider/vitest`
6
+
7
+ ### VitestBrowser
8
+
9
+ The Vitest adapter: a browser layer for `@effect/vitest`, with `TestRun` for the test that's running.
10
+
11
+ *layers*
12
+
13
+ - `const layer: <E, R>(backend: Layer.Layer<Browser.Browser, E, R>) => Layer.Layer<Browser.Browser | TestRun.TestRun, E, R>`
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jonathan Powers
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 CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # @usestrider/vitest
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run [Strider](https://usestrider.dev) tests under Vitest: each test is an Effect program, with one browser per file and
4
+ a fresh context for each page.
5
+
6
+ **Status:** pre-release.
7
+
8
+ ```sh
9
+ pnpm add -D vitest @effect/vitest @effect/platform-node effect @usestrider/browser @usestrider/vitest
10
+ ```
11
+
12
+ `VitestBrowser.layer` provides the backend you give it, unchanged, plus `TestRun`, the test that's running:
13
+
14
+ ```ts
15
+ import { NodeServices } from "@effect/platform-node"
16
+ import { layer } from "@effect/vitest"
17
+ import { Browser, Expect } from "@usestrider/browser"
18
+ import { Chromium } from "@usestrider/browser/chromium"
19
+ import { VitestBrowser } from "@usestrider/vitest"
20
+ import { Config, Effect, Layer } from "effect"
21
+
22
+ const ChromiumLive = Chromium.layerConfig({
23
+ executablePath: Config.String("CHROMIUM_PATH")
24
+ }).pipe(Layer.provide(NodeServices.layer))
25
+
26
+ layer(VitestBrowser.layer(ChromiumLive), { excludeTestServices: true })("checkout", (it) => {
27
+ it.effect("adds a product to the cart", () =>
28
+ Effect.gen(function*() {
29
+ const page = yield* Browser.newPage()
30
+ yield* page.goto("https://shop.example.com")
31
+ yield* page.getByRole("button", { name: "Add to cart" }).click()
32
+ yield* page.getByText("1 item").pipe(Expect.toBeVisible)
33
+ }))
34
+ })
35
+ ```
36
+
37
+ [Tests with Vitest](https://usestrider.dev/docs/tools/testing) covers concurrent pages, attaching files to a test, and a
38
+ fake browser for events. The source is at https://github.com/usestrider/strider.
39
+
40
+ MIT licensed.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The Vitest adapter: a browser layer for `@effect/vitest`, with `TestRun` for the test that's running.
3
+ *
4
+ * `VitestBrowser.layer` passes the backend's layer through unchanged. The package's peer dependency is `vitest` 5.
5
+ *
6
+ * @stability unstable
7
+ * @since 0.1.0
8
+ */
9
+ import type * as Browser from "@usestrider/browser/Browser";
10
+ import { TestRun } from "@usestrider/browser/test";
11
+ import * as Layer from "effect/Layer";
12
+ declare module "vitest" {
13
+ interface TestArtifactRegistry {
14
+ "@usestrider/browser": {
15
+ readonly type: "@usestrider/browser";
16
+ readonly artifact: TestRun.TestArtifact["_tag"];
17
+ readonly attachments: Array<{
18
+ readonly path: string;
19
+ readonly contentType: string;
20
+ }>;
21
+ };
22
+ }
23
+ }
24
+ /**
25
+ * Provides the backend you pass, unchanged, plus `TestRun` for the current test.
26
+ *
27
+ * **Details**
28
+ *
29
+ * The browser starts where the layer is built: given to `@effect/vitest`'s `layer`, once for the block, whose tests
30
+ * share it; provided to one effect, as below, once for that effect.
31
+ *
32
+ * **Example** (Providing a browser to a test)
33
+ *
34
+ * ```ts import.meta.vitest
35
+ * import { Browser } from "@usestrider/browser"
36
+ * import { Chromium } from "@usestrider/browser/chromium"
37
+ * import { VitestBrowser } from "@usestrider/vitest"
38
+ * import { Effect } from "effect"
39
+ *
40
+ * const test = Effect.scoped(Effect.gen(function*() {
41
+ * const page = yield* Browser.newPage({ focus: "emulated" })
42
+ * yield* page.goto("https://shop.example.com")
43
+ * })).pipe(
44
+ * Effect.provide(
45
+ * VitestBrowser.layer(Chromium.layer({ executablePath: "/usr/bin/chromium" }))
46
+ * )
47
+ * )
48
+ * ```
49
+ *
50
+ * @stability unstable
51
+ * @category layers
52
+ * @since 0.1.0
53
+ */
54
+ export declare const layer: <E, R>(backend: Layer.Layer<Browser.Browser, E, R>) => Layer.Layer<Browser.Browser | TestRun.TestRun, E, R>;
55
+ //# sourceMappingURL=VitestBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestBrowser.d.ts","sourceRoot":"","sources":["../src/VitestBrowser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,QAAQ,QAAQ,CAAC;IACtB,UAAU,oBAAoB;QAC5B,qBAAqB,EAAE;YACrB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAA;YACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;YAC/C,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC;gBAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SACrF,CAAA;KACF;CACF;AA8DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,WACf,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,KAC1C,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAkE,CAAA"}
@@ -0,0 +1,79 @@
1
+ import { TestRun } from "@usestrider/browser/test";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import { recordArtifact, TestRunner } from "vitest";
5
+ /** The test's path: its file, then each suite, then the test. */
6
+ const pathOf = test => {
7
+ const names = [test.name];
8
+ for (let suite = test.suite; suite !== undefined; suite = suite.suite) {
9
+ if (suite.name !== "") names.unshift(suite.name);
10
+ }
11
+ return [test.file.name, ...names].join(" > ");
12
+ };
13
+ const env = name => globalThis.process?.env?.[name] ?? "";
14
+ const infoOf = test => new TestRun.TestInfo({
15
+ project: test?.file.projectName ?? "",
16
+ file: test?.file.filepath ?? "",
17
+ id: test === undefined ? "" : pathOf(test),
18
+ attempt: test?.result?.retryCount ?? 0,
19
+ worker: env("VITEST_POOL_ID"),
20
+ shard: env("VITEST_SHARD")
21
+ });
22
+ const contentType = {
23
+ Trace: "application/zip",
24
+ Har: "application/json",
25
+ Screenshot: "image/png"
26
+ };
27
+ /** `TestRun` for Vitest: the current test, read each time, and its artifacts. */
28
+ const testRun = {
29
+ get info() {
30
+ return infoOf(TestRunner.getCurrentTest());
31
+ },
32
+ attach: artifact => Effect.suspend(() => {
33
+ const test = TestRunner.getCurrentTest();
34
+ if (test === undefined) {
35
+ return Effect.logWarning(`TestRun.attach: no test is running, so ${artifact.path} wasn't attached`);
36
+ }
37
+ const type = artifact._tag === "Screenshot" && /\.jpe?g$/i.test(artifact.path) ? "image/jpeg" : contentType[artifact._tag];
38
+ return Effect.tryPromise(() => recordArtifact(test, {
39
+ type: "@usestrider/browser",
40
+ artifact: artifact._tag,
41
+ attachments: [{
42
+ path: artifact.path,
43
+ contentType: type
44
+ }]
45
+ })).pipe(Effect.asVoid, Effect.catch(error => Effect.logWarning(`TestRun.attach: Vitest didn't attach ${artifact.path}: ${error.message}`)));
46
+ })
47
+ };
48
+ /**
49
+ * Provides the backend you pass, unchanged, plus `TestRun` for the current test.
50
+ *
51
+ * **Details**
52
+ *
53
+ * The browser starts where the layer is built: given to `@effect/vitest`'s `layer`, once for the block, whose tests
54
+ * share it; provided to one effect, as below, once for that effect.
55
+ *
56
+ * **Example** (Providing a browser to a test)
57
+ *
58
+ * ```ts import.meta.vitest
59
+ * import { Browser } from "@usestrider/browser"
60
+ * import { Chromium } from "@usestrider/browser/chromium"
61
+ * import { VitestBrowser } from "@usestrider/vitest"
62
+ * import { Effect } from "effect"
63
+ *
64
+ * const test = Effect.scoped(Effect.gen(function*() {
65
+ * const page = yield* Browser.newPage({ focus: "emulated" })
66
+ * yield* page.goto("https://shop.example.com")
67
+ * })).pipe(
68
+ * Effect.provide(
69
+ * VitestBrowser.layer(Chromium.layer({ executablePath: "/usr/bin/chromium" }))
70
+ * )
71
+ * )
72
+ * ```
73
+ *
74
+ * @stability unstable
75
+ * @category layers
76
+ * @since 0.1.0
77
+ */
78
+ export const layer = backend => Layer.merge(backend, Layer.succeed(TestRun.TestRun, testRun));
79
+ //# sourceMappingURL=VitestBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitestBrowser.js","names":[],"sources":["../src/VitestBrowser.ts"],"sourcesContent":[null],"mappings":"AASA,SAAS,OAAO,QAAQ,0BAA0B;AAClD,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,SAAS,cAAc,EAAE,UAAU,QAAQ,QAAQ;AAcnD;AACA,MAAM,MAAM,GAAI,IAAgB,IAAY;EAC1C,MAAM,KAAK,GAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;EACxC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE;IACrE,IAAI,KAAK,CAAC,IAAI,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;EAClD;EACA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;AAC/C,CAAC;AAED,MAAM,GAAG,GAAI,IAAY,IACtB,UAA2F,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC,IAC/G,EAAE;AAEN,MAAM,MAAM,GAAI,IAA4B,IAC1C,IAAI,OAAO,CAAC,QAAQ,CAAC;EACnB,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;EACrC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;EAC/B,EAAE,EAAE,IAAI,KAAK,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;EAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,IAAI,CAAC;EACtC,MAAM,EAAE,GAAG,CAAC,gBAAgB,CAAC;EAC7B,KAAK,EAAE,GAAG,CAAC,cAAc;CAC1B,CAAC;AAEJ,MAAM,WAAW,GAAiD;EAChE,KAAK,EAAE,iBAAiB;EACxB,GAAG,EAAE,kBAAkB;EACvB,UAAU,EAAE;CACb;AAED;AACA,MAAM,OAAO,GAAoB;EAC/B,IAAI,IAAI;IACN,OAAO,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;EAC5C,CAAC;EACD,MAAM,EAAG,QAAQ,IACf,MAAM,CAAC,OAAO,CAAC,MAAK;IAClB,MAAM,IAAI,GAAG,UAAU,CAAC,cAAc,EAAE;IACxC,IAAI,IAAI,KAAK,SAAS,EAAE;MACtB,OAAO,MAAM,CAAC,UAAU,CAAC,0CAA0C,QAAQ,CAAC,IAAI,kBAAkB,CAAC;IACrG;IACA,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAC1E,YAAY,GACZ,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,OAAO,MAAM,CAAC,UAAU,CAAC,MACvB,cAAc,CAAC,IAAI,EAAE;MACnB,IAAI,EAAE,qBAAqB;MAC3B,QAAQ,EAAE,QAAQ,CAAC,IAAI;MACvB,WAAW,EAAE,CAAC;QAAE,IAAI,EAAE,QAAQ,CAAC,IAAI;QAAE,WAAW,EAAE;MAAI,CAAE;KACzD,CAAC,CACH,CAAC,IAAI,CACJ,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,KAAK,CAAE,KAAK,IACjB,MAAM,CAAC,UAAU,CAAC,wCAAwC,QAAQ,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAC7F,CACF;EACH,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,OAAO,MAAM,KAAK,GAChB,OAA2C,IACc,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @stability unstable
3
+ * @since 0.1.0
4
+ */
5
+ /**
6
+ * @stability unstable
7
+ * @since 0.1.0
8
+ */
9
+ export * as VitestBrowser from "./VitestBrowser.ts";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @stability unstable
3
+ * @since 0.1.0
4
+ */
5
+ // @barrel: Auto-generated exports. Do not edit manually.
6
+ /**
7
+ * @stability unstable
8
+ * @since 0.1.0
9
+ */
10
+ export * as VitestBrowser from "./VitestBrowser.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;AAKA;AAEA;;;;AAIA,OAAO,KAAK,aAAa,MAAM,oBAAoB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@usestrider/vitest",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "homepage": "https://usestrider.dev",
7
+ "description": "Vitest for @usestrider/browser: the current test as TestRun, and its artifacts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/usestrider/strider.git",
11
+ "directory": "packages/vitest"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/usestrider/strider/issues"
15
+ },
16
+ "keywords": [
17
+ "effect",
18
+ "typescript",
19
+ "browser",
20
+ "vitest"
21
+ ],
22
+ "sideEffects": [],
23
+ "exports": {
24
+ "./package.json": "./package.json",
25
+ ".": "./dist/index.js",
26
+ "./*": "./dist/*.js",
27
+ "./index": null
28
+ },
29
+ "files": [
30
+ "src/**/*.ts",
31
+ "dist/**/*.js",
32
+ "dist/**/*.js.map",
33
+ "dist/**/*.d.ts",
34
+ "dist/**/*.d.ts.map",
35
+ "INDEX.md"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "provenance": true
40
+ },
41
+ "peerDependencies": {
42
+ "@usestrider/browser": "^0.1.1",
43
+ "effect": "^4.0.6",
44
+ "vitest": "^5.0.5"
45
+ },
46
+ "devDependencies": {
47
+ "@usestrider/browser": "^0.1.1",
48
+ "@usestrider/utils": "^0.0.0",
49
+ "effect": "^4.0.6",
50
+ "vitest": "^5.0.5"
51
+ },
52
+ "scripts": {
53
+ "codegen": "strider-utils barrel",
54
+ "build": "tsc -b tsconfig.json && pnpm babel",
55
+ "babel": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
56
+ "check": "tsc -b tsconfig.json"
57
+ }
6
58
  }
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The Vitest adapter: a browser layer for `@effect/vitest`, with `TestRun` for the test that's running.
3
+ *
4
+ * `VitestBrowser.layer` passes the backend's layer through unchanged. The package's peer dependency is `vitest` 5.
5
+ *
6
+ * @stability unstable
7
+ * @since 0.1.0
8
+ */
9
+ import type * as Browser from "@usestrider/browser/Browser"
10
+ import { TestRun } from "@usestrider/browser/test"
11
+ import * as Effect from "effect/Effect"
12
+ import * as Layer from "effect/Layer"
13
+ import { recordArtifact, TestRunner } from "vitest"
14
+
15
+ declare module "vitest" {
16
+ interface TestArtifactRegistry {
17
+ "@usestrider/browser": {
18
+ readonly type: "@usestrider/browser"
19
+ readonly artifact: TestRun.TestArtifact["_tag"]
20
+ readonly attachments: Array<{ readonly path: string; readonly contentType: string }>
21
+ }
22
+ }
23
+ }
24
+
25
+ type RunnerTest = NonNullable<ReturnType<typeof TestRunner.getCurrentTest>>
26
+
27
+ /** The test's path: its file, then each suite, then the test. */
28
+ const pathOf = (test: RunnerTest): string => {
29
+ const names: Array<string> = [test.name]
30
+ for (let suite = test.suite; suite !== undefined; suite = suite.suite) {
31
+ if (suite.name !== "") names.unshift(suite.name)
32
+ }
33
+ return [test.file.name, ...names].join(" > ")
34
+ }
35
+
36
+ const env = (name: string): string =>
37
+ (globalThis as { readonly process?: { readonly env?: Record<string, string | undefined> } }).process?.env?.[name] ??
38
+ ""
39
+
40
+ const infoOf = (test: RunnerTest | undefined): TestRun.TestInfo =>
41
+ new TestRun.TestInfo({
42
+ project: test?.file.projectName ?? "",
43
+ file: test?.file.filepath ?? "",
44
+ id: test === undefined ? "" : pathOf(test),
45
+ attempt: test?.result?.retryCount ?? 0,
46
+ worker: env("VITEST_POOL_ID"),
47
+ shard: env("VITEST_SHARD")
48
+ })
49
+
50
+ const contentType: Record<TestRun.TestArtifact["_tag"], string> = {
51
+ Trace: "application/zip",
52
+ Har: "application/json",
53
+ Screenshot: "image/png"
54
+ }
55
+
56
+ /** `TestRun` for Vitest: the current test, read each time, and its artifacts. */
57
+ const testRun: TestRun.TestRun = {
58
+ get info() {
59
+ return infoOf(TestRunner.getCurrentTest())
60
+ },
61
+ attach: (artifact) =>
62
+ Effect.suspend(() => {
63
+ const test = TestRunner.getCurrentTest()
64
+ if (test === undefined) {
65
+ return Effect.logWarning(`TestRun.attach: no test is running, so ${artifact.path} wasn't attached`)
66
+ }
67
+ const type = artifact._tag === "Screenshot" && /\.jpe?g$/i.test(artifact.path)
68
+ ? "image/jpeg"
69
+ : contentType[artifact._tag]
70
+ return Effect.tryPromise(() =>
71
+ recordArtifact(test, {
72
+ type: "@usestrider/browser",
73
+ artifact: artifact._tag,
74
+ attachments: [{ path: artifact.path, contentType: type }]
75
+ })
76
+ ).pipe(
77
+ Effect.asVoid,
78
+ Effect.catch((error) =>
79
+ Effect.logWarning(`TestRun.attach: Vitest didn't attach ${artifact.path}: ${error.message}`)
80
+ )
81
+ )
82
+ })
83
+ }
84
+
85
+ /**
86
+ * Provides the backend you pass, unchanged, plus `TestRun` for the current test.
87
+ *
88
+ * **Details**
89
+ *
90
+ * The browser starts where the layer is built: given to `@effect/vitest`'s `layer`, once for the block, whose tests
91
+ * share it; provided to one effect, as below, once for that effect.
92
+ *
93
+ * **Example** (Providing a browser to a test)
94
+ *
95
+ * ```ts import.meta.vitest
96
+ * import { Browser } from "@usestrider/browser"
97
+ * import { Chromium } from "@usestrider/browser/chromium"
98
+ * import { VitestBrowser } from "@usestrider/vitest"
99
+ * import { Effect } from "effect"
100
+ *
101
+ * const test = Effect.scoped(Effect.gen(function*() {
102
+ * const page = yield* Browser.newPage({ focus: "emulated" })
103
+ * yield* page.goto("https://shop.example.com")
104
+ * })).pipe(
105
+ * Effect.provide(
106
+ * VitestBrowser.layer(Chromium.layer({ executablePath: "/usr/bin/chromium" }))
107
+ * )
108
+ * )
109
+ * ```
110
+ *
111
+ * @stability unstable
112
+ * @category layers
113
+ * @since 0.1.0
114
+ */
115
+ export const layer = <E, R>(
116
+ backend: Layer.Layer<Browser.Browser, E, R>
117
+ ): Layer.Layer<Browser.Browser | TestRun.TestRun, E, R> => Layer.merge(backend, Layer.succeed(TestRun.TestRun, testRun))
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @stability unstable
3
+ * @since 0.1.0
4
+ */
5
+
6
+ // @barrel: Auto-generated exports. Do not edit manually.
7
+
8
+ /**
9
+ * @stability unstable
10
+ * @since 0.1.0
11
+ */
12
+ export * as VitestBrowser from "./VitestBrowser.ts"