{"_id":"@codeforbreakfast/bun-test-effect","_rev":"2-cdffdf439ccceb884134aa52acd537f5","name":"@codeforbreakfast/bun-test-effect","dist-tags":{"latest":"0.4.1"},"versions":{"0.4.0":{"name":"@codeforbreakfast/bun-test-effect","version":"0.4.0","keywords":["bun","bun-test","effect","effect-ts","testing","test-runner","functional-programming","typescript"],"author":{"name":"CodeForBreakfast"},"license":"MIT","_id":"@codeforbreakfast/bun-test-effect@0.4.0","maintainers":[{"name":"graemef","email":"graemef@gmail.com"}],"homepage":"https://github.com/CodeForBreakfast/eventsourcing#readme","bugs":{"url":"https://github.com/CodeForBreakfast/eventsourcing/issues"},"dist":{"shasum":"51559b9506a5f3db20e3a5ef8bbf26a6c263406b","tarball":"https://registry.npmjs.org/@codeforbreakfast/bun-test-effect/-/bun-test-effect-0.4.0.tgz","fileCount":12,"integrity":"sha512-0Klmd8nmKACTEo7DCIDBvxdNOVG1rXJVvqUETZrkSYomUL2hH9KsNkqzjPHpuyge0OKALSlo1msR0lVcxLgP5g==","signatures":[{"sig":"MEYCIQCfCk0vuCkfVS3p1FdkG9k6fadrprpb0Uf2/KPoo1u5kwIhALOsOwLPeVcqy9jIAR9CCx7DFZgbaulcioEfg55r4Dci","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36019},"type":"module","exports":{".":"./src/index.ts","./eslint":"./src/eslint/index.js"},"gitHead":"572968daaa6a79b98fb010df951d5f75bcd7f1c7","scripts":{"lint":"echo 'Using root lint config'","test":"bun test","typecheck":"tsc --noEmit","validate:docs":"bun ../../scripts/validate-markdown-examples.ts","validate:pack":"bun pm pack --dry-run","check:publishable":"npm view $npm_package_name@$npm_package_version version >/dev/null 2>&1 && exit 1 || exit 0"},"_npmUser":{"name":"graemef","email":"graemef@gmail.com"},"repository":{"url":"git+https://github.com/CodeForBreakfast/eventsourcing.git","type":"git","directory":"packages/bun-test-effect"},"_npmVersion":"11.6.2","description":"Testing utilities for Effect with Bun, providing effect-native test runners and assertions (adapted from @effect/vitest)","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"effect":"3.18.4"},"peerDependencies":{"effect":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/bun-test-effect_0.4.0_1764059392257_0.8273288709615443","host":"s3://npm-registry-packages-npm-production"}},"0.4.1":{"name":"@codeforbreakfast/bun-test-effect","version":"0.4.1","type":"module","license":"MIT","author":{"name":"CodeForBreakfast"},"description":"Testing utilities for Effect with Bun, providing effect-native test runners and assertions (adapted from @effect/vitest)","repository":{"type":"git","url":"git+https://github.com/CodeForBreakfast/eventsourcing.git","directory":"packages/bun-test-effect"},"keywords":["bun","bun-test","effect","effect-ts","testing","test-runner","functional-programming","typescript"],"publishConfig":{"access":"public"},"exports":{".":"./src/index.ts","./eslint":"./src/eslint/index.js"},"scripts":{"typecheck":"tsc --noEmit","lint":"echo 'Using root lint config'","test":"bun test","validate:pack":"bun pm pack --dry-run","check:publishable":"npm view $npm_package_name@$npm_package_version version >/dev/null 2>&1 && exit 1 || exit 0","validate:docs":"bun ../../scripts/validate-markdown-examples.ts"},"peerDependencies":{"effect":">=3.0.0"},"devDependencies":{"effect":"3.19.9"},"gitHead":"dc9291553d278cb59572e9fb1569fe0c01194eea","_id":"@codeforbreakfast/bun-test-effect@0.4.1","bugs":{"url":"https://github.com/CodeForBreakfast/eventsourcing/issues"},"homepage":"https://github.com/CodeForBreakfast/eventsourcing#readme","_nodeVersion":"20.19.6","_npmVersion":"11.6.2","dist":{"integrity":"sha512-/+og3ocFNlVK/q3ECnXdmENjh1LjY98qhBSjrD3iTnM0CDhE94usnjg1A8b8TBUnHLzCl7mMuwF+kX3MSa/J3w==","shasum":"4536da6de7e9204436fb6691eb85da2eac660ea3","tarball":"https://registry.npmjs.org/@codeforbreakfast/bun-test-effect/-/bun-test-effect-0.4.1.tgz","fileCount":12,"unpackedSize":36019,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@codeforbreakfast%2fbun-test-effect@0.4.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF2jGfO4lPscP3H+aKznS5/QLBOrSoDxLlFXsDbAX5L3AiBob2GKd2VcqUQCgG8qdG6uUaq4y0kU9BXnTZ42hIxMSA=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:95cc6256-0d40-4457-84be-534db2985eaf"}},"directories":{},"maintainers":[{"name":"graemef","email":"graemef@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bun-test-effect_0.4.1_1765443327435_0.021128738777706824"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-25T08:29:52.145Z","modified":"2025-12-11T08:55:27.948Z","0.4.0":"2025-11-25T08:29:52.449Z","0.4.1":"2025-12-11T08:55:27.583Z"},"bugs":{"url":"https://github.com/CodeForBreakfast/eventsourcing/issues"},"author":{"name":"CodeForBreakfast"},"license":"MIT","homepage":"https://github.com/CodeForBreakfast/eventsourcing#readme","keywords":["bun","bun-test","effect","effect-ts","testing","test-runner","functional-programming","typescript"],"repository":{"type":"git","url":"git+https://github.com/CodeForBreakfast/eventsourcing.git","directory":"packages/bun-test-effect"},"description":"Testing utilities for Effect with Bun, providing effect-native test runners and assertions (adapted from @effect/vitest)","maintainers":[{"name":"graemef","email":"graemef@gmail.com"}],"readme":"# @codeforbreakfast/bun-test-effect\n\nTesting utilities for Effect with Bun, providing effect-native test runners and assertions. Adapted from [@effect/vitest](https://github.com/Effect-TS/effect/tree/main/packages/vitest).\n\n## Installation\n\n```bash\nbun add --dev @codeforbreakfast/bun-test-effect\n```\n\n## Features\n\nThis package provides:\n\n- **Effect-aware test runners** that handle Effect execution automatically\n- **Scoped test runners** for tests requiring resource management\n- **Layer sharing** across multiple tests with automatic setup/teardown\n- **Effect-native assertions** for Option, Either, and equality checks\n- **ESLint rules** to enforce best practices in Effect tests\n\n## Basic Usage\n\n### Effect Test Runners\n\nUse `it.effect` or `it.scoped` instead of plain `test` to run Effects in your tests:\n\n```typescript\nimport { describe, it, expect } from '@codeforbreakfast/bun-test-effect';\nimport { Effect } from 'effect';\n\ndescribe('MyService', () => {\n  it.effect('should process data', () =>\n    Effect.gen(function* () {\n      const result = yield* Effect.succeed(42);\n      expect(result).toBe(42);\n    })\n  );\n\n  it.scoped('should handle resources', () =>\n    Effect.gen(function* () {\n      const resource = yield* Effect.acquireRelease(Effect.succeed('resource'), () => Effect.void);\n      expect(resource).toBe('resource');\n    })\n  );\n});\n```\n\n### Test Variants\n\nAll test runners support standard Bun test modifiers:\n\n```typescript\nimport { it } from '@codeforbreakfast/bun-test-effect';\nimport { Effect } from 'effect';\n\ndeclare const condition: boolean;\n\nit.effect.skip('skipped test', () => Effect.void);\nit.effect.only('focused test', () => Effect.void);\nit.effect.skipIf(condition)('conditional skip', () => Effect.void);\nit.effect.runIf(condition)('conditional run', () => Effect.void);\nit.effect.fails('expected to fail', () => Effect.fail('error'));\nit.effect.each([1, 2, 3])('parameterized test', (n: number) => Effect.succeed(n));\n```\n\n### Live vs Test Environment\n\n- `it.effect` / `it.scoped` - Runs with `TestServices` (test clock, etc.)\n- `it.live` / `it.scopedLive` - Runs with real services (real clock, etc.)\n\n```typescript\nimport { it } from '@codeforbreakfast/bun-test-effect';\nimport { Effect } from 'effect';\n\nit.live('uses real time', () =>\n  Effect.gen(function* () {\n    yield* Effect.sleep('100 millis'); // Actually waits 100ms\n  })\n);\n```\n\n### Sharing Layers\n\nUse `it.layer` to share a Layer across multiple tests with automatic lifecycle management:\n\n```typescript\nimport { describe, it } from '@codeforbreakfast/bun-test-effect';\nimport { Effect, Layer, Context } from 'effect';\n\nclass Database extends Context.Tag('Database')<\n  Database,\n  { query: (sql: string) => Effect.Effect<unknown> }\n>() {}\n\nconst DatabaseLive = Layer.succeed(Database, {\n  query: (sql) => Effect.succeed({ rows: [] }),\n});\n\ndescribe('Database tests', () => {\n  it.layer(DatabaseLive)((it) => {\n    it.effect('should query', () =>\n      Effect.gen(function* () {\n        const db = yield* Database;\n        const result = yield* db.query('SELECT 1');\n        // ...\n      })\n    );\n\n    it.effect('should insert', () =>\n      Effect.gen(function* () {\n        const db = yield* Database;\n        // Layer is shared, setup runs once\n      })\n    );\n  });\n});\n```\n\n## Effect-Native Assertions\n\nFor testing within Effect pipelines, use the provided assertion utilities:\n\n```typescript\nimport {\n  it,\n  expectSome,\n  expectNone,\n  expectRight,\n  expectLeft,\n  assertEqual,\n  expectTrue,\n  expectFalse,\n} from '@codeforbreakfast/bun-test-effect';\nimport { Effect, Option, Either, pipe } from 'effect';\n\nit.effect('assertion examples', () =>\n  Effect.gen(function* () {\n    // Option assertions\n    yield* expectSome(Option.some(42));\n    yield* expectNone(Option.none());\n\n    // Either assertions\n    yield* expectRight(Either.right('success'));\n    yield* expectLeft(Either.left('error'));\n\n    // Equality (uses Effect's Equal)\n    yield* pipe(42, assertEqual(42));\n\n    // Boolean assertions with custom messages\n    yield* pipe(true, expectTrue('should be true'));\n    yield* pipe(false, expectFalse('should be false'));\n  })\n);\n```\n\n## Utilities\n\n### Silent Logger\n\nSuppress log output during tests:\n\n```typescript\nimport { it, silentLogger } from '@codeforbreakfast/bun-test-effect';\nimport { Effect, pipe } from 'effect';\n\nit.effect('quiet test', () =>\n  pipe(\n    Effect.gen(function* () {\n      yield* Effect.log(\"This won't appear in test output\");\n    }),\n    Effect.provide(silentLogger)\n  )\n);\n```\n\n### Flaky Test Retry\n\nRetry flaky tests with exponential backoff:\n\n```typescript\nimport { it, flakyTest } from '@codeforbreakfast/bun-test-effect';\nimport { Effect } from 'effect';\n\nit.effect('eventually succeeds', () =>\n  flakyTest(\n    Effect.gen(function* () {\n      // Test that may fail intermittently\n    }),\n    '30 seconds' // timeout\n  )\n);\n```\n\n## ESLint Rules\n\nThis package includes ESLint rules to enforce best practices in Effect tests:\n\n```javascript\n// eslint.config.mjs\nimport buntestPlugin from '@codeforbreakfast/bun-test-effect/eslint';\n\nexport default [\n  {\n    files: ['**/*.test.ts', '**/*.spec.ts'],\n    plugins: {\n      'bun-test-effect': buntestPlugin,\n    },\n    rules: {\n      'bun-test-effect/no-runPromise-in-tests': 'error',\n      'bun-test-effect/no-runSync-in-tests': 'error',\n      'bun-test-effect/prefer-effect-assertions': 'warn',\n    },\n  },\n];\n```\n\n### Available Rules\n\n| Rule                       | Description                                                    |\n| -------------------------- | -------------------------------------------------------------- |\n| `no-runPromise-in-tests`   | Forbids `Effect.runPromise` in tests - use `it.effect` instead |\n| `no-runSync-in-tests`      | Forbids `Effect.runSync` in tests - use `it.effect` instead    |\n| `prefer-effect-assertions` | Suggests using Effect-native assertions over manual matching   |\n\n## API Reference\n\n### Test Runners\n\n| Export                       | Description                                |\n| ---------------------------- | ------------------------------------------ |\n| `it.effect`                  | Run Effect tests with TestServices         |\n| `it.scoped`                  | Run scoped Effect tests with TestServices  |\n| `it.live`                    | Run Effect tests with real services        |\n| `it.scopedLive`              | Run scoped Effect tests with real services |\n| `it.layer(layer)`            | Share a Layer across multiple tests        |\n| `flakyTest(effect, timeout)` | Retry flaky tests                          |\n\n### Assertions\n\n| Export                  | Description                          |\n| ----------------------- | ------------------------------------ |\n| `expectSome(option)`    | Assert Option is Some, return value  |\n| `expectNone(option)`    | Assert Option is None                |\n| `expectRight(either)`   | Assert Either is Right, return value |\n| `expectLeft(either)`    | Assert Either is Left, return value  |\n| `assertEqual(expected)` | Assert equality using Effect's Equal |\n| `expectTrue(message)`   | Assert boolean is true               |\n| `expectFalse(message)`  | Assert boolean is false              |\n\n### Utilities\n\n| Export                 | Description                                |\n| ---------------------- | ------------------------------------------ |\n| `silentLogger`         | Logger that discards all output            |\n| `addEqualityTesters()` | Register Effect equality matchers with Bun |\n\n### Re-exports\n\nAll exports from `bun:test` are re-exported for convenience:\n\n```typescript\nimport { describe, test, expect, beforeAll, afterAll } from '@codeforbreakfast/bun-test-effect';\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}