create-codeverse-test
v1.0.4
Published
Zero-config CLI that scaffolds an automated-testing project with Jest from CodeVerse's official template — just run it with npx.
Maintainers
Readme
create-codeverse-test
Zero-config CLI that scaffolds a new automated-testing project with Jest from CodeVerse's official template. Run one command, answer two questions, and get a project that is ready for you to write unit tests, mocks and tests for code with external dependencies — with dependencies installed and the folder opened in VS Code.
It does not run your tests, lint your code, or set up CI. Its only job is to create the starting project so you can begin writing tests immediately.
Quick start
npx create-codeverse-test@latestNo global install required.
What the command does
When you run it, the CLI:
Asks two questions in an interactive wizard:
- Project name — lowercase letters, digits and hyphens only (no spaces, cannot start or end
with a hyphen, max 214 characters). This becomes the new folder name and the
namefield in the generatedpackage.json. - Test type — Unit or Dependencies (see Test types).
- Project name — lowercase letters, digits and hyphens only (no spaces, cannot start or end
with a hyphen, max 214 characters). This becomes the new folder name and the
Creates a new folder named after your project, inside the current directory, and copies the template into it. If a folder with that name already exists, the CLI stops with an error.
Adds mock/dependency examples — only if you picked Dependencies — by merging extra files over the base template (this replaces
tests/nome-do-script.test.jswith a version that also contains a mocks section).Updates
package.jsonin the generated project, setting itsnameto your project name.Installs dependencies inside the new folder:
- always:
npm install -D jest@latest jest-html-reporters@latest - Dependencies only:
npm install axios@latest
If the install fails, the CLI keeps going and tells you the exact command to run manually.
- always:
Removes the
.gitfolder that came from the template, so you start with a clean history.Opens the project in VS Code by running
code .. If thecodecommand is not on yourPATH, it prints the project path so you can open it yourself.Prints the next steps (how to open the integrated terminal and run
npm test).
Your tests are never run automatically — you run npm test when the project is ready.
Test types
| Type | Extra install | What changes |
| --------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Unit | — | Plain template: just Jest and JavaScript (ES Modules). For testing functions, classes, scenarios, negative cases, boundary values and business rules. |
| Dependencies | axios@latest | Adds a describe('Mocks com jest.fn()') block to tests/nome-do-script.test.js covering mockReturnValue, mockResolvedValue, mockRejectedValue, toHaveBeenCalled, toHaveBeenCalledTimes and toHaveBeenCalledWith. Axios is included as the HTTP client for those scenarios (real or mocked API). |
What the generated project contains
- Jest and jest-html-reporters — always the latest version at scaffold time.
- JavaScript with ES Modules (
"type": "module", run through--experimental-vm-modules). src/nome-do-seu-script.js— a sample function for you to replace.tests/nome-do-script.test.js— a teaching suite covering the core matchers (toBe,toEqual,toContain,toBeTruthy,toBeFalsy,toHaveLength,toBeCloseTo), plus the mocks block when you chose Dependencies.jest.reporters.config.mjs— Jest config that adds the HTML reporter..gitignore— ignoresnode_modules/, generated reports and coverage, logs,.envfiles and editor/OS files.
Scripts in the generated project
| Script | Command | Purpose |
| ----------------- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| npm test | Jest with --runInBand --verbose | Runs the whole suite, one test at a time, with per-test output. |
| npm run report | npm test -- --coverage --json --outputFile=coverage/relatorio.json | Runs the suite with coverage and writes a JSON report to coverage/relatorio.json. |
| npm run dashboard | npm test -- --config jest.reporters.config.mjs | Runs the suite and generates an HTML report at _html-report/index.html (opens automatically). |
Requirements
- Node.js >= 18.17
- npm
- VS Code with the
codecommand on yourPATH— optional; if missing, the CLI just prints the project path for you to open manually.
License
MIT © CodeVerse
