# Forceinjection Domain Driven Design Skills Nx Monorepo Generator

> Nx Monorepo Generator - Jest Configuration Workflow

- Skill: `tomevault-io/forceinjection-domain-driven-design-skills-nx-monorepo-gener` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/forceinjection-domain-driven-design-skills-nx-monorepo-gener`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/forceinjection-domain-driven-design-skills-nx-monorepo-gener/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/forceinjection-domain-driven-design-skills-nx-monorepo-gener

---


# Nx Monorepo Generator - Jest Configuration Workflow

The Nx Jest generator produces defaults that conflict with this workspace's standards. This skill ensures all mandatory post-generation fixes are applied.

## Phase 1: Determine Project Type

Identify the project type before generating:

| Type | Examples | Testing Needs |
|------|----------|---------------|
| **UI** | web apps, mobile | Full stack: jest-dom, user-event, MSW |
| **Node** | server, APIs | jest-dom + conditional MSW |
| **Logic** | schemas, utils | Basic Jest only |

**How to identify**:
- Check `project.json` executors (React/Next.js = UI, Node = server)
- Schema/utility libraries = Logic
- When uncertain, ask the user

## Phase 2: Generate Configuration

```bash
pnpm exec nx g @nx/jest:configuration <project-name>
```

Creates: `jest.config.ts`, `tsconfig.spec.json`, updates `project.json`

**Warning**: Generated config has incorrect defaults - proceed to Phase 3.

## Phase 3: Post-Generation Fixes

Execute ALL applicable steps. See `references/post-gen-checklist.md` for full details.

| Step | UI | Node | Logic | Script |
|------|:--:|:----:|:-----:|--------|
| Install testing libs | ✅ | ✅ | ❌ | `scripts/install-testing-libs.sh` |
| Create jest.setup.ts | ✅ | ❌ | ❌ | Manual |
| Update jest.config.ts | ✅ | ❌ | ❌ | Manual |
| Fix moduleResolution | ✅ | ✅ | ✅ | `scripts/fix-tsconfig-spec.sh` |
| Verify Jest types | ✅ | ✅ | ✅ | `scripts/validate-jest-config.sh` |
| Clean production config | ✅ | ✅ | ✅ | `scripts/validate-jest-config.sh` |

### Critical Fix: TypeScript moduleResolution

In `tsconfig.spec.json`, change:
- `"module": "commonjs"` → `"module": "nodenext"`
- `"moduleResolution": "node10"` → `"moduleResolution": "nodenext"`

**Why**: Workspace uses `customConditions` requiring modern module resolution.

## Phase 4: Validation

```bash
# Automated validation
scripts/validate-jest-config.sh <project-path>

# Run tests
pnpm exec nx run <project-name>:test
```

**Success indicators**:
- ✅ Tests run without TypeScript errors
- ✅ No module resolution warnings
- ✅ Coverage reports generate correctly

## References

- `references/post-gen-checklist.md` - Step-by-step checklist with code examples
- `references/jest-config-patterns.md` - Configuration structure and rationale
- `references/testing-standards.md` - user-event, MSW, jest-dom patterns

## Scripts

- `scripts/validate-jest-config.sh <path>` - Validate configuration against standards
- `scripts/install-testing-libs.sh <type> <path>` - Install testing packages by project type
- `scripts/fix-tsconfig-spec.sh <path>` - Auto-fix moduleResolution settings

## Key Principle

**Generated code rarely matches monorepo patterns.** Post-generation fixes are MANDATORY. This skill ensures consistency and prevents pattern drift that causes mysterious failures.

---
> Source: [ForceInjection/domain-driven-design-skills](https://github.com/ForceInjection/domain-driven-design-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-06-15 -->

