@tst-studio/tst
v0.2.0
Published
LLM-powered unit test generator CLI by TST-Studio
Downloads
5
Readme
About the Project
tst is a tool from TST-Studio that automatically generates unit tests for JavaScript and TypeScript code, helping developers maintain flow, reduce boilerplate, and improve test coverage.
Built with TypeScript, Vitest, OCLIF, ts-morph, and LLMs (like OpenAI, Claude, etc).
Example
Math.ts
export function add(a: number, b: number): number {
return a + b;
}Generated test (math.test.ts):
import { describe, it, expect } from 'vitest';
import { add } from './math';
describe('add', () => {
it('adds two numbers', () => {
expect(add(2, 3)).toBe(5);
});
});Table of Contents
Tech Stack
- Language: TypeScript
- Test Runner: Vitest
- CLI Framework: OCLIF
- LLM Integration: OpenAI
- AST Parsing: ts-morph
Features
- Generate unit tests automatically from source files
- Output structured, runnable Vitest test files
- CLI interface for smooth developer workflow
Getting Started
You can use this tool in your own repositories.
Installation
$ npm install @tst-studio/tstConfiguration
Automatically add tst.config.json configuration file:
$ tst configure --outFormat=sameLocation
Wrote tst.config.jsonUsage
Generate tests for a file
tst generate ./src/queue.jsThis will submit the whole file to the LLM and create a test file in the appropriate location.
How to Contribute
Help us build the most seamless automated test generation tool possible.
Issues & PRs welcome!
- Repo: https://github.com/TST-Studio/tst-cli
- Issues: https://github.com/TST-Studio/tst-cli/issues
Before opening a PR:
- Write tests where appropriate (or use this tool! 😀 )
- Run
npm run format:check && npm test.
Prerequisites
Ensure you have the following installed:
Tech Stack
Language:
CLI Framework:
Parsing & Utilities:
Developer Tooling:
- ESLint + Prettier – Code linting and formatting
- Husky – Git hooks (e.g., lint on commit)
- tsx – Run TypeScript directly in dev mode
- TypeScript (tsc) – Compiler
- @types/node – Node.js type definitions
OCLIF Support:
- oclif – CLI scaffolding and packaging
- @oclif/plugin-legacy – Legacy command support
oclif.manifest.json– Generated CLI manifest
Developing
The dev.js command is a development command that represents the tst command but will continue to compile Typescript on the fly while developing.
$ bin/dev.js
LLM-powered unit test generator CLI by TST-Studio
VERSION
@tst-studio/tst/0.1.0 darwin-arm64 node-v22.17.1
USAGE
$ tst [COMMAND]
TOPICS
auth Write API key to local .env or create one
COMMANDS
configure Create or update tst.config.json
generate Generate Vitest tests from a source fileTo test outside of the tst-cli repo (e.g., to test against a different tsconfig.json file without breaking the tst command), use another repository like this sandbox repository:
https://github.com/TST-Studio/demo-test-script
Publish (maintainers only)
Use this checklist when cutting a new release to npm.
0) Prerequisites
- [x] You are a maintainer for the @tst-studio org/package.
- [x] Your npm account has 2FA enabled.
- [x] You’re logged in:
npm whoami(login withnpm loginif needed)
1) Branch is clean
Ensure:
- All code is formatted consistently:
npm run format README.mdis up to date- All code is committed
Ensure main is clean:
$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree cleanNext steps may fail if main is not clean.
2) Prep the release
Verify the package contents
- Build the
tstcommand:
npm run build- Pack the
tstcommand and inspect the tarball
npm pack- View a publish dry run. Sanity check what is included:
npm publish --dry-run3) Bump the version (SemVer)
This step updates package.json, creates a git tag (e.g., v0.1.1), and commits.
Determine if this is:
A patch (bug fix. No functionality changed)
A minor release (functionality was added)
A major release (backwards incompatible changes added)
Ensure main is clean (see step 1).
NOTE: The following instructions need to have single quotes (not double quotes) as they can include an exclamation mark (used by the "npm version" command). Without the single quotes, the exclamation mark can be interpreted as a history command by the shell.
If Patch
npm version patch -m 'chore(release): %s'If Minor
npm version minor -m 'feat!: %s'If Major
npm version major -m 'feat!: %s'4) Publish to NPM
npm publish5) Push tag and verify
git push --follow-tags
npm view @tst-studio/tst versionCommon Pitfalls
EPUBLISHCONFLICT: That version already exists
E403 / not authorized to publish: You’re not a maintainer for @tst-studio/tst under the org; ask an admin to add you or your team.
2FA errors: Provide --otp=(Your code) or re-enable 2FA on your account.
Wrong files in the tarball: Use
.npmignoreor files inpackage.json; re-run npm pack to confirm.
Documentation
Output Location
You can control where test files are generated using the outFormat option in tst.config.json.
sameLocation
tst generate ./src/queue.js --outFormat=sameLocationProduces:
./src/queue.test.jstestDir
tst generate ./src/queue.js --outFormat=testDir --outBaseSrc=./src --outBaseTest=./testsProduces:
./tests/queue.test.js
Configuration
tst expects a configuration file in your project root:
tst.config.json
Example:
{
"provider": "openai",
"model": "gpt-4o-mini",
"outFormat": "testDir",
"outBaseSrc": "./src",
"outBaseTest": "./tests",
"astLibrary": "ts-morph",
"testingFramework": "vitest",
"moduleType": "module"
}Fields
- provider:
"openai"(future:"anthropic","vertex","azure-openai","bedrock", etc.) - model:
"gpt-4o-mini"(future:"gpt-4o","gpt-4.1","gpt-4.1-mini") - outFormat:
"sameLocation" | "testDir" - outBaseSrc: Root including
src(used whenoutFormatistestDir) - outBaseTest: Root including
tests(used whenoutFormatistestDir) - astLibrary:
"ts-morph"(future:"babel") - testingFramework:
"vitest"(future:"jest", etc.) - moduleType:
"module"(future:"commonjs", etc.)
Commands
Configure
tst configureGenerates tst.config.json. You can also specify fields via flags:
tst configure --provider=openai --model=gpt-4o-mini --outFormat=testDir --outBaseSrc=./src --outBaseTest=./tests --astLibrary=ts-morph --testingFramework=vitest --moduleType=moduleGenerate
tst generate ./src/utils/math.js # Generate unit tests for an entire file
tst generate ./src/utils/math.js --function=add # Generate unit tests for a specific function
Auth
tst auth set --provider=openai --api-key=$TST_OPENAI_API_KEY
# Store API key for a specific provider
tst auth status
# Show current authentication statusOther Commands
tst --help # Display available commands and usage
tst --version # Show the current CLI versionEnvironment Variables
export TST_OPENAI_API_KEY=sk-...The API key is required to communicate with the LLM.
License
MIT (c) TST-Studio
