test: add coverage for fileExists helper#89
Closed
fuleinist wants to merge 1 commit into
Closed
Conversation
Adds a test file for the fileExists() helper that covers:
- true for an existing file (via writeFile then access)
- false for a non-existent file
- true for a directory path (fs.access succeeds on dirs)
- false for a non-existent nested path
Also adds vitest.config.ts with explicit include patterns so
> @builder.io/micro-agent@0.1.5 test
> vitest run --exclude src/tests/integration
�[1m�[46m RUN �[49m�[22m �[36mv4.1.1 �[39m�[90m/home/admin/.openclaw/workspace/micro-agent�[39m
�[32m✓�[39m src/helpers/dependency-files.test.ts �[2m(�[22m�[2m10 tests�[22m�[2m)�[22m�[32m 10�[2mms�[22m�[39m
�[31m❯�[39m src/helpers/config.test.ts �[2m(�[22m�[2m0 test�[22m�[2m)�[22m
�[31m❯�[39m src/helpers/llm.test.ts �[2m(�[22m�[2m0 test�[22m�[2m)�[22m
�[31m❯�[39m src/helpers/apply-unified-diff.test.ts �[2m(�[22m�[2m0 test�[22m�[2m)�[22m
�[32m✓�[39m src/helpers/generate-ascii-tree.test.ts �[2m(�[22m�[2m7 tests�[22m�[2m)�[22m�[32m 7�[2mms�[22m�[39m
�[32m✓�[39m src/helpers/file-exists.test.ts �[2m(�[22m�[2m4 tests�[22m�[2m)�[22m�[32m 13�[2mms�[22m�[39m
�[32m✓�[39m src/helpers/remove-initial-slash.test.ts �[2m(�[22m�[2m3 tests�[22m�[2m)�[22m�[32m 5�[2mms�[22m�[39m
�[2m�[90m↓�[39m�[22m src/tests/ternary/simplify.test.ts �[2m(�[22m�[2m1 test�[22m�[2m | �[22m�[33m1 skipped�[39m�[2m)�[22m
�[32m✓�[39m src/helpers/remove-backticks.test.ts �[2m(�[22m�[2m1 test�[22m�[2m)�[22m�[32m 3�[2mms�[22m�[39m
�[32m✓�[39m src/tests/angular-parser/parse.test.ts �[2m(�[22m�[2m2 tests�[22m�[2m)�[22m�[32m 17�[2mms�[22m�[39m
�[2m Test Files �[22m �[1m�[31m3 failed�[39m�[22m�[2m | �[22m�[1m�[32m6 passed�[39m�[22m�[2m | �[22m�[33m1 skipped�[39m�[90m (10)�[39m
�[2m Tests �[22m �[1m�[32m27 passed�[39m�[22m�[2m | �[22m�[33m1 skipped�[39m�[90m (28)�[39m
�[2m Start at �[22m 00:11:59
�[2m Duration �[22m 1.37s�[2m (transform 666ms, setup 0ms, import 1.56s, tests 54ms, environment 1ms)�[22m picks up src/**/*.test.ts files — the default
vitest include (src/**/*.test.{ts,tsx}) was missing .test.ts
files in src/helpers/.
Closes issue BuilderIO#2 (good first issue: add some tests)
Author
|
Closing as stale (no activity for 4+ weeks). Happy to reopen if still relevant — just drop a comment and I'll pick it back up. |
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.
Summary
Adds a test file for the
fileExists()helper insrc/helpers/file-exists.test.ts, closing the "good first issue" (issue #2: "Add some tests").Also adds
vitest.config.tswith explicit include patterns sonpm testpicks upsrc/**/*.test.tsfiles — the existing config was missing.test.tsinsrc/helpers/.Tests added
writeFile, confirmsfileExistsreturnstruefalsefor a path that never existedfs.accesssucceeds on directories too, so the helper correctly returnstruefor directory pathsfalsefor deeply nested non-existent pathsFiles changed
src/helpers/file-exists.test.ts— new test file (4 test cases)vitest.config.ts— new config withinclude: [src/**/*.test.ts, src/**/*.test.mjs]Closes #2