Skip to content
Back to skills

Effect Ts Testing

ASecurity

Testing guidelines and patterns for Effect-based code.

  • 755 stars
  • 0 votes
  • 1 copy
  • 6 views
  • Added February 8, 2026
developmenttypescripttesting

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill effect-ts-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Effect Ts Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Effect Ts Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-effect-ts-testing/badge)](https://www.skillsdirectory.com/skills/majiayu000-effect-ts-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: effect-ts-testing
description: Testing guidelines and patterns for Effect-based code.
---

# Effect-TS Testing Skill

Use this skill when writing or reviewing tests for Effect-based code.

## Effect testing rules (for `*.spec.*` files)

When testing a method that returns an `Effect` type, use the `@effect/vitest`
package.

- Use `import { it } from '@effect/vitest'` as opposed to importing `it` from
  regular vitest.
- Usage:
  ```typescript
  it.effect('test name', () => {
     return Effect.gen(...)
  })
  ```
- Use `it.layer()` to provide test dependencies when your Effect requires
  specific services:
  ```typescript
  it.layer(Layer.fresh(IncrementalIdGenerator))((it) => {
    it.effect('test name', () => {
      return Effect.gen(...)
    })
  })
  ```

## Testing for type-safety

Use `tsafe` package for compile-time type assertions to validate type safety in
tests.

- Import: `import { assert } from 'tsafe'` and `import type { Equals } from 'tsafe'`
- Usage: `assert<Equals<ActualType, ExpectedType>>()` - validates exact type
  equality at compile time

## Test time helpers

Never use `new Date()` in tests. Always use `yield* DateTime.now` and convert to
`Date` if needed.

```typescript
import { DateTime, Effect } from 'effect';

const nowDateTime = yield* DateTime.now;
const now = DateTime.toDateUtc(nowDateTime);
```

## Schema decoding with decodeUnknown

When decoding unknown values using Effect schemas, always use the
`decodeUnknown` function exported from `zerospin` instead of
`Schema.decodeUnknown` directly.

- Import: `import { decodeUnknown } from 'zerospin'`
- Always specify `onExcessProperty`: `'error'`, `'ignore'`, or `'preserve'`
  based on your needs
- Map errors to `ZerospinError` with code `'failed-to-decode-unknown'`

**In Effect.gen contexts:**
```typescript
import { decodeUnknown } from 'zerospin';
import { ZerospinError } from '@zerospin/error';
import { Effect } from 'effect';

const decoded = yield* decodeUnknown({
  onExcessProperty: 'error', // or 'ignore' or 'preserve'
  schema: MySchema,
  value: unknownValue,
}).pipe(
  Effect.mapError((error) => {
    return new ZerospinError({
      code: 'failed-to-decode-unknown',
      message: error.message,
      cause: error,
    });
  })
);
```

**In async/await contexts:**
```typescript
import { decodeUnknown } from 'zerospin';
import { ZerospinError } from '@zerospin/error';
import { Effect } from 'effect';

const decoded = await Effect.runPromise(
  decodeUnknown({
    onExcessProperty: 'error',
    schema: MySchema,
    value: unknownValue,
  }).pipe(
    Effect.mapError((error) => {
      return new ZerospinError({
        code: 'failed-to-decode-unknown',
        message: error.message,
        cause: error,
      });
    })
  )
);
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.