This project demonstrates Test-Driven Development (TDD) using Large Language Models (LLMs). The workflow consists of three main steps:
- Generate Test Skeleton: Create a basic structure for tests
- Generate Complete Tests: Flesh out the test skeleton with actual test cases
- Generate Function Implementation: Create a function that passes all the tests
graph TD
A[Test skeleton created] --> B[Complete tests generated]
B --> C[Function implementation generated]
C --> D[Tests passing]
Run the complete TDD workflow:
npm run tdd
This will:
- Generate a test skeleton for a random function
- Generate a complete test file from the skeleton
- Generate a function implementation that passes all the tests
You can also run each step individually:
# Generate a test skeleton
npx tsx generateTestSkeleton.ts
# Generate a complete test from a skeleton
npx tsx generateTestFileFromSkeleton.ts
# Generate a function implementation from a test file
npx tsx generateFunctionFromSpec.ts
The project includes several utility functions in the utils
directory:
generateTestSkeleton.ts
: Creates a test skeleton using OpenAIgenerateTestFromSkeleton.ts
: Generates complete tests from a skeletongenerateFunctionFromSpec.ts
: Creates a function implementation that passes testschat.ts
: Utility for interacting with OpenAIreadFileContent.ts
: Utility for reading file contentwriteFileContent.ts
: Utility for writing file contentrunTests.ts
: Utility for running tests
- Node.js
- npm
- OpenAI API key (set as OPENAI_API_KEY environment variable)