Skip to content

Add Jest test infrastructure and tests for CLI package#51

Open
htsukamoto5 wants to merge 4 commits into
mainfrom
test/cli-tests
Open

Add Jest test infrastructure and tests for CLI package#51
htsukamoto5 wants to merge 4 commits into
mainfrom
test/cli-tests

Conversation

@htsukamoto5
Copy link
Copy Markdown
Contributor

Summary

  • Adds Jest + @sucrase/jest-plugin test infrastructure to packages/cli
  • Tests for utils.ts, validatefunctions.ts, and data.ts (27 tests total, all passing)
  • Modernizes saveTextToPath from callback-based fs.writeFile to async/await with fs.promises.writeFile

Notes

index.ts and handlefiles.ts are intentionally out of scope — testing the interactive @inquirer/prompts entrypoint would require a separate mocking effort.

Test plan

  • cd packages/cli && npx jest — all 27 tests pass
  • Verify no regressions in packages/metadata tests

🤖 Generated with Claude Code

htsukamoto5 and others added 3 commits June 1, 2026 15:01
Sets up jest with @sucrase/jest-plugin (node environment) and adds 14
tests across two suites: expandHomeDir and generatePath in utils.test.ts,
validateDirectory and validateJson in validatefunctions.test.ts. Tests
use real temp directories/files via os.tmpdir() rather than mocks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…essDirectory

13 tests covering the core data functions using real temp directories.
processDirectory tests cover CSV/JSON files, unsupported file types,
one-level subdirectory recursion, and dataset_description.json handling.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaced callback-based fs.writeFile with fs.promises.writeFile so
saveTextToPath returns a Promise. Updated the two saveTextToPath tests
to await the call directly, removing the setTimeout/done workaround.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 1, 2026

🦋 Changeset detected

Latest commit: da2e8d2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@jspsych/metadata-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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