🧠💥 Auto-generate Jest test cases for your JavaScript/TypeScript code using AI — so you can ship confidently without writing a single test.
JestSmith is a CLI tool that uses AI to automatically generate Jest test cases for any JavaScript or TypeScript project, including:
- ✅ React components
- ✅ Node.js backend logic
- ✅ NestJS modules (controllers, services, routes)
- ✅ Any framework or custom business logic
- ⚡ One-command test generation
- 📂 Folder support (generate tests for entire modules)
- 🧠 AI-powered (works better with a short explanation)
- 📝 Outputs clean, readable, idiomatic Jest tests
- 🧰 Framework-agnostic (React, Node, Angular, NestJS, etc.)
- 🛠️ TypeScript-native
npm install -g jestsmithjestsmith ./src/components/LoginForm.tsx --describe "A login form with Formik + Yup that hits a login API on submit"jestsmith ./src/modules/user --describe "This is a NestJS User module with CRUD operations"✅ The tool will:
- Parse each file
- Understand file relationships (controllers, services, routes)
- Generate relevant Jest test cases into a
__tests__/folder or in the--out-dir
| Option | Description |
|---|---|
--describe |
(optional) Add context so the AI writes better tests |
--outDir |
(optional) Customize the output folder for test files |
--dry-run |
(coming soon) Preview the generated output without saving |
Given a file like:
// LoginForm.tsx
const LoginForm = () => {
const formik = useFormik({
/* yup validation */
});
const handleSubmit = async () => {
await api.login(formik.values);
};
return <form onSubmit={handleSubmit}>...</form>;
};Running:
jestsmith LoginForm.tsx --describe "React login form using Formik and Yup"Might generate:
// __tests__/LoginForm.test.tsx
import { render, fireEvent } from '@testing-library/react';
import LoginForm from '../LoginForm';
describe('LoginForm', () => {
it('calls login API on successful form submission', async () => {
...
});
});Under the hood, JestSmith:
- Uses AST parsing to understand your code structure
- Sends intelligently prepared prompts to an LLM (like GPT)
- Applies Jest syntax best practices
- Writes test files based on your code and explanation
- ✅ Provide a short
--describefor context - ✅ Keep functions/components modular and clean
- ✅ Use TypeScript where possible for better inference
- ✅ Use meaningful function/component names
-
--dry-runto preview generated code - Support
.jestsmithrcconfig files - Built-in Prettier formatting
- Estimate test coverage based on function count
- VSCode extension support
PRs, ideas, and contributions are welcome!
# clone the repo
git clone https://github.com/ahsansheikh94/jestsmith.git
cd jestsmith
# install deps
npm install
# build the CLI
npm run build
# test locally
node dist/bin/index.js ./src/example.ts --describe "Login form with API call"This repo uses Changesets for automated versioning + changelogs + npm publishing.
To release:
npx changeset # describe the change
git commit -am "chore: version bump"
git pushGitHub Actions will:
- Create a release PR
- Tag version
- Publish to npm automatically
You’ll need to set
NPM_TOKENin GitHub Secrets.
MIT © Ahsan Sheikh
Found a bug? Have feature ideas?
→ Open an issue
Love the tool?
→ ⭐ Star it and share it with your team!