Add Vitest coverage tooling and unit tests for core utils - #4
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
Add Vitest coverage tooling and unit tests for core utils#4devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description of Changes
Coverage analysis: the repo had no test runner at all (
npm testwasecho "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 — thesrc/utilshelpers pluscreateCommandand the template selector. Overall statement coverage goes from 0% to 49%, withsrc/utilsat 98% andsrc/utils/env+src/utils/gitat 100%.Tooling:
vitest+@vitest/coverage-v8devDependencies,vitest.config.ts, andtest/test:watch/test:coveragescripts..jsextensions (import { log } from 'utils/logger.js'), which Node/tsup resolve but Vitest does not, so the config maps them back to the TypeScript sources:src/**/*.tsand excludessrc/scripts/**,COMMAND_TEMPLATE/**,_template/**,src/types/**, and test files.Tests (38, colocated as
*.test.ts): allLogLevel/LogColorbranches inlogger,.nextquickrcread/parse/exit paths,.env.localpresence and missing-variable reporting,install-pluginsmerge semantics and its failing-plugin and unreadable-package.jsonpaths, all fourcheck-gitexports including the dirty-tree prompt in both answers,setup-git-repo,check-directory,package-manager,createCommandplugin filtering, theNonetemplate path, and recursivetemplate-copy-transfer.Approach: fs-touching modules run against real
fs.mkdtempdirectories withprocess.cwd()stubbed, rather than mockingfs;child_process,inquirer, andopenare mocked, so nothing shells out to real git/npm.process.exitis 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,authand their installer plugins) andsrc/index.ts, which are thin orchestration overcreate-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