# Module not found during tests

Classification: dependency
Frameworks: Jest, pytest, CI
Canonical: https://automationtester.in/failures/dependency-module-not-found

## Recognizable error

```text
Cannot find module 'package-name'
```

## What it means

The test runtime could not resolve a package, local module, generated artifact, or configured path alias.

## Ranked causes, checks, and fixes

### 1. The dependency is missing from the locked install

A transitive or globally installed local dependency hid the omission.

Diagnostic: Install from the lockfile in a clean environment and inspect direct dependencies.

Fix: Declare the package in the correct production or test dependency group.

### 2. Path aliases differ between compiler and runner

TypeScript may resolve an alias that Jest or another runner does not know.

Diagnostic: Compare tsconfig paths with the test runner's module mapping.

Fix: Derive both configurations from one alias source or mirror them explicitly.

### 3. A generated file was not created

Schema clients, code generation, or build artifacts may be absent in CI.

Diagnostic: Check the generation step and expected file before starting tests.

Fix: Run deterministic generation after install and cache only compatible output.

## Prevention

- Test clean lockfile installs.
- Align resolver configuration.
- Verify generated artifacts before collection.

## Primary references

- [Jest module paths](https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring)

Triage this failure locally: https://automationtester.in/tools/test-failure-triage