Skip to content

test: add coverage for fileExists helper#89

Closed
fuleinist wants to merge 1 commit into
BuilderIO:mainfrom
fuleinist:test/file-exists-coverage
Closed

test: add coverage for fileExists helper#89
fuleinist wants to merge 1 commit into
BuilderIO:mainfrom
fuleinist:test/file-exists-coverage

Conversation

@fuleinist

Copy link
Copy Markdown

Summary

Adds a test file for the fileExists() helper in src/helpers/file-exists.test.ts, closing the "good first issue" (issue #2: "Add some tests").

Also adds vitest.config.ts with explicit include patterns so npm test picks up src/**/*.test.ts files — the existing config was missing .test.ts in src/helpers/.

Tests added

  • returns true for an existing file — creates a temp file with writeFile, confirms fileExists returns true
  • returns false for a non-existent file — confirms false for a path that never existed
  • returns true for a directory pathfs.access succeeds on directories too, so the helper correctly returns true for directory paths
  • returns false for a non-existent nested path — confirms false for deeply nested non-existent paths

Files changed

  • src/helpers/file-exists.test.ts — new test file (4 test cases)
  • vitest.config.ts — new config with include: [src/**/*.test.ts, src/**/*.test.mjs]

Closes #2

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)
@fuleinist

Copy link
Copy Markdown
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.

@fuleinist fuleinist closed this Jun 11, 2026
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.

Add some tests

1 participant