Skip to content

Simplify some tests, remove some tests - #33

Merged
k0d13 merged 1 commit into
mainfrom
kodie/further-test-changes
Jul 18, 2026
Merged

Simplify some tests, remove some tests#33
k0d13 merged 1 commit into
mainfrom
kodie/further-test-changes

Conversation

@k0d13

@k0d13 k0d13 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Developer Experience

    • Improved editor file nesting for both TypeScript and TSX test files.
    • Streamlined recommended editor settings and spell-check configuration.
  • Testing

    • Consolidated test configuration for more consistent test execution across packages.
    • Expanded parser coverage for JavaScript, TypeScript, and JSX message patterns.
    • Added coverage for configuration loading, caching, and error handling.
    • Simplified test fixtures and improved test maintainability.

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
saykit Ready Ready Preview, Comment Jul 18, 2026 5:24pm

@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4cd9ce9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions github-actions Bot added dependencies Updates or changes related to project dependencies tests Modifications, additions, or fixes related to testing package: config Related to @saykit/config and the CLI package: unplugin Related to unplugin-saykit package: transform-js Related to @saykit/transform-js package: transform-jsx Related to @saykit/transform-jsx labels Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The pull request consolidates Vitest configuration, adds resolveConfig coverage, updates catalogue storage tests, rewrites JavaScript and JSX parser tests to use parsed source, removes obsolete tests and fixtures, and simplifies editor recommendations and settings.

Changes

Test infrastructure and configuration

Layer / File(s) Summary
Unified test setup and config resolution
vitest.config.ts, package.json, packages/config/src/features/loader/resolve.test.ts
Vitest uses shared path resolution and test discovery, vite-tsconfig-paths is added, and config loading, caching, transpilation, and error handling are tested.
Catalogue test maintenance
packages/config/src/features/catalogue/storage.test.ts, packages/config/src/features/catalogue/*
Catalogue storage tests use a local JSON bucket, while obsolete catalogue, watcher, worker, and fixture tests are removed.

Transformer parser tests

Layer / File(s) Summary
Parsed JavaScript and JSX inputs
packages/transform-js/src/parser.test.ts, packages/transform-jsx/src/parser.test.ts
Tests parse TypeScript and JSX snippets directly and cover message descriptors, comments, branches, fallbacks, invalid inputs, and nested expressions.
Test comment cleanup
packages/transform-js/src/generator.test.ts, packages/transform-jsx/src/generator.test.ts, packages/plugin-unplugin/src/index.test.ts
Standalone comments describing unchanged test helpers and mocks are removed.

Editor configuration

Layer / File(s) Summary
VS Code recommendations and nesting
.vscode/extensions.json, .vscode/settings.json
Todo Tree recommendations and settings are removed, and .test.tsx files are added to TypeScript file nesting.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • k0d13/saykit#12: Related parser test rewrites and expected message-shape updates in transform-js.
  • k0d13/saykit#29: Related Vitest configuration changes involving project setup, aliases, and server-only stubbing.

Poem

A bunny parses code with care,
Through JSX fields and branches fair.
Tests hop together, configs align,
Old crumbs vanish from the line.
“Nibble-approved!” the rabbit sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the changes, but it is too generic to convey the main update clearly. Use a more specific title that mentions the test simplification and test removals in the config and transform packages.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kodie/further-test-changes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/config/src/features/loader/resolve.test.ts (1)

12-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mock process.cwd instead of mutating the global working directory.

Using process.chdir mutates the working directory for the entire process. This is a known anti-pattern in testing, as it can cause flaky behaviour if tests run concurrently or asynchronous operations are pending. Mocking process.cwd is a safer alternative that preserves test isolation.

  • packages/config/src/features/loader/resolve.test.ts#L12-L13: replace the lifecycle process.chdir calls with a mock (requires importing vi from vitest).
-beforeEach(() => process.chdir(dir));
-afterEach(() => process.chdir(cwd));
+beforeEach(() => { vi.spyOn(process, 'cwd').mockReturnValue(dir); });
+afterEach(() => { vi.restoreAllMocks(); });
  • packages/config/src/features/loader/resolve.test.ts#L34-L35: update the inline reset to override the mock instead of changing the real directory.
-    process.chdir(cwd);
+    vi.spyOn(process, 'cwd').mockReturnValue(cwd);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/config/src/features/loader/resolve.test.ts` around lines 12 - 13, In
packages/config/src/features/loader/resolve.test.ts lines 12-13, import vi from
vitest and replace the beforeEach/afterEach process.chdir calls with a
process.cwd mock that returns the test directory and restores isolation
afterward. At lines 34-35, update the inline reset to override the process.cwd
mock rather than changing the real working directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/config/src/features/catalogue/storage.test.ts`:
- Around line 44-50: Update the test “passes existing content to the formatter
when the file already exists” to spy on the formatter and capture its
invocation, importing vi from vitest as needed. Configure the mock to preserve
or expose the existingContent argument, then assert that the second write passes
the previously written catalogue content to the formatter instead of only
asserting that the call resolves.

---

Nitpick comments:
In `@packages/config/src/features/loader/resolve.test.ts`:
- Around line 12-13: In packages/config/src/features/loader/resolve.test.ts
lines 12-13, import vi from vitest and replace the beforeEach/afterEach
process.chdir calls with a process.cwd mock that returns the test directory and
restores isolation afterward. At lines 34-35, update the inline reset to
override the process.cwd mock rather than changing the real working directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2cfa1fa6-f7a2-4cda-88a9-3b16dc5dc03f

📥 Commits

Reviewing files that changed from the base of the PR and between 419be3a and 4cd9ce9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (18)
  • .vscode/extensions.json
  • .vscode/settings.json
  • package.json
  • packages/config/src/__fixtures__/bucket.ts
  • packages/config/src/features/catalogue/extractor.test.ts
  • packages/config/src/features/catalogue/merge.test.ts
  • packages/config/src/features/catalogue/path.test.ts
  • packages/config/src/features/catalogue/storage.test.ts
  • packages/config/src/features/loader/resolve.test.ts
  • packages/config/src/features/watch.test.ts
  • packages/config/src/features/workers/extract-worker.test.ts
  • packages/config/src/features/workers/shared.test.ts
  • packages/plugin-unplugin/src/index.test.ts
  • packages/transform-js/src/generator.test.ts
  • packages/transform-js/src/parser.test.ts
  • packages/transform-jsx/src/generator.test.ts
  • packages/transform-jsx/src/parser.test.ts
  • vitest.config.ts
💤 Files with no reviewable changes (10)
  • packages/transform-jsx/src/generator.test.ts
  • packages/config/src/fixtures/bucket.ts
  • packages/transform-js/src/generator.test.ts
  • packages/config/src/features/watch.test.ts
  • packages/config/src/features/catalogue/extractor.test.ts
  • packages/config/src/features/catalogue/merge.test.ts
  • packages/config/src/features/workers/extract-worker.test.ts
  • packages/config/src/features/workers/shared.test.ts
  • packages/config/src/features/catalogue/path.test.ts
  • packages/plugin-unplugin/src/index.test.ts

Comment on lines 44 to 50
it('passes existing content to the formatter when the file already exists', async () => {
const path = join(dir, 'existing.json');
await writeCatalogueMessages(makeBucket(), 'en', [message], path);
await writeCatalogueMessages(bucket, 'en', [message], path);
// Second write should read the existing file first (no throw).
await expect(
writeCatalogueMessages(makeBucket(), 'en', [message], path),
).resolves.toBeUndefined();
await expect(writeCatalogueMessages(bucket, 'en', [message], path)).resolves.toBeUndefined();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert that existingContent is correctly passed to the formatter.

The test title states that it verifies existing content is passed to the formatter. However, the mock formatter currently drops this argument, and the test merely checks that the function resolves without throwing. To ensure functional correctness, spy on the formatter and explicitly assert that it receives the existing content.

💡 Proposed fix (requires importing `vi` from `vitest`)
   it('passes existing content to the formatter when the file already exists', async () => {
     const path = join(dir, 'existing.json');
     await writeCatalogueMessages(bucket, 'en', [message], path);
-    // Second write should read the existing file first (no throw).
-    await expect(writeCatalogueMessages(bucket, 'en', [message], path)).resolves.toBeUndefined();
+    
+    const spy = vi.spyOn(bucket.formatter, 'stringify');
+    await writeCatalogueMessages(bucket, 'en', [message], path);
+    
+    expect(spy).toHaveBeenCalledWith(
+      [message],
+      expect.objectContaining({ existingContent: JSON.stringify([message]) })
+    );
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('passes existing content to the formatter when the file already exists', async () => {
const path = join(dir, 'existing.json');
await writeCatalogueMessages(makeBucket(), 'en', [message], path);
await writeCatalogueMessages(bucket, 'en', [message], path);
// Second write should read the existing file first (no throw).
await expect(
writeCatalogueMessages(makeBucket(), 'en', [message], path),
).resolves.toBeUndefined();
await expect(writeCatalogueMessages(bucket, 'en', [message], path)).resolves.toBeUndefined();
});
it('passes existing content to the formatter when the file already exists', async () => {
const path = join(dir, 'existing.json');
await writeCatalogueMessages(bucket, 'en', [message], path);
const spy = vi.spyOn(bucket.formatter, 'stringify');
await writeCatalogueMessages(bucket, 'en', [message], path);
expect(spy).toHaveBeenCalledWith(
[message],
expect.objectContaining({ existingContent: JSON.stringify([message]) })
);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/config/src/features/catalogue/storage.test.ts` around lines 44 - 50,
Update the test “passes existing content to the formatter when the file already
exists” to spy on the formatter and capture its invocation, importing vi from
vitest as needed. Configure the mock to preserve or expose the existingContent
argument, then assert that the second write passes the previously written
catalogue content to the formatter instead of only asserting that the call
resolves.

@k0d13
k0d13 merged commit ae00b81 into main Jul 18, 2026
10 checks passed
@k0d13
k0d13 deleted the kodie/further-test-changes branch July 18, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Updates or changes related to project dependencies package: config Related to @saykit/config and the CLI package: transform-js Related to @saykit/transform-js package: transform-jsx Related to @saykit/transform-jsx package: unplugin Related to unplugin-saykit tests Modifications, additions, or fixes related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant