Skip to content

Add Vitest coverage tooling and unit tests for core utils - #4

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1787594509-add-unit-tests
Open

Add Vitest coverage tooling and unit tests for core utils#4
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1787594509-add-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Coverage analysis: the repo had no test runner at all (npm test was echo "Error: no test specified" && exit 1), so every module was at 0%. This adds Vitest with v8 coverage and covers the modules carrying the most untested branching logic — the src/utils helpers plus createCommand and the template selector. Overall statement coverage goes from 0% to 49%, with src/utils at 98% and src/utils/env + src/utils/git at 100%.

Tooling:

  • vitest + @vitest/coverage-v8 devDependencies, vitest.config.ts, and test / test:watch / test:coverage scripts.
  • Sources import each other via baseUrl-relative specifiers with .js extensions (import { log } from 'utils/logger.js'), which Node/tsup resolve but Vitest does not, so the config maps them back to the TypeScript sources:
alias: [{ find: /^(commands|types|utils)\/(.+)\.js$/, replacement: path.resolve(repoRoot, 'src/$1/$2.ts') }]
  • Coverage counts src/**/*.ts and excludes src/scripts/**, COMMAND_TEMPLATE/**, _template/**, src/types/**, and test files.

Tests (38, colocated as *.test.ts): all LogLevel/LogColor branches in logger, .nextquickrc read/parse/exit paths, .env.local presence and missing-variable reporting, install-plugins merge semantics and its failing-plugin and unreadable-package.json paths, all four check-git exports including the dirty-tree prompt in both answers, setup-git-repo, check-directory, package-manager, createCommand plugin filtering, the None template path, and recursive template-copy-transfer.

Approach: fs-touching modules run against real fs.mkdtemp directories with process.cwd() stubbed, rather than mocking fs; child_process, inquirer, and open are mocked, so nothing shells out to real git/npm. process.exit is stubbed to throw a sentinel so exit paths are assertable. Assertions avoid ANSI codes so they hold in both TTY and non-TTY runs. No source files were modified.

Uncovered remainders are the command entrypoints (init, deploy, database, auth and their installer plugins) and src/index.ts, which are thin orchestration over create-next-app, npm, and interactive prompts — worth covering separately if you want them.

Related Issues

None

Link to Devin session: https://app.devin.ai/sessions/5a924e887d5f4c51ae9503d76d7715c0
Requested by: @lox-bot

lox-bot and others added 2 commits August 24, 2026 18:06
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant