Skip to content

Run tests against built plugin in CI and other minor tweaks - #21

Merged
nstepien merged 3 commits into
mainfrom
test-against-build
Mar 7, 2026
Merged

nstepien merged 3 commits into
mainfrom
test-against-build

Conversation

@nstepien

@nstepien nstepien commented Mar 7, 2026 •

Copy link
Copy Markdown
Owner

Also enabled test coverage by default, removed test:coverage command

Summary by CodeRabbit

  • New Features

    • Plugin now accepts an optional configuration (null/undefined tolerated); defaults applied at runtime. Configuration fields accept null/undefined.
  • Documentation

    • Refined command table formatting and removed outdated test coverage instructions.
    • Added TODO for stricter type checking.
  • Tests

    • Test runner: coverage enabled, randomized execution, and narrower test discovery patterns.
  • Chores

    • Added repository ignore rule, removed deprecated test:coverage script, and updated build/test configuration files.

Also enabled test coverage by default, removed `test:coverage` command
@nstepien nstepien self-assigned this Mar 7, 2026
@coderabbitai

coderabbitai Bot commented Mar 7, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d5de557-ec02-4d21-a0c1-eb407d8fe297

📥 Commits

Reviewing files that changed from the base of the PR and between 44753b1 and 45b4752.

📒 Files selected for processing (1)
  • src/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/index.ts

📝 Walkthrough

Walkthrough

Relaxed plugin Configuration types to allow null/undefined and moved defaults to runtime; updated tests and Vitest config (CI-aware aliasing, explicit test include, coverage enabled, sequence shuffle); adjusted TypeScript configs and removed coverage script; minor docs and .gitignore edits.

Changes

Cohort / File(s) Summary
Repository ignore
/.gitignore
Added rule to ignore /.claude.
Documentation
AGENTS.md, README.md
Formatting changes to AGENTS.md; removed test:coverage mentions from README and added TODO for noUncheckedIndexedAccess; widened documented Configuration types in README.
Package scripts
package.json
Removed test:coverage script; other scripts unchanged.
TypeScript configs
tsconfig.base.json, tsconfig.test.json, tsconfig.tools.json
Removed allowSyntheticDefaultImports and jsx from base; tsconfig.test.json removes types: ["node"] and adds path alias ecij/plugin → ./src/index.ts; tsconfig.tools.json adds exactOptionalPropertyTypes: false and includes vitest.config.ts.
Vitest & tests
vitest.config.ts, test/plugin.test.ts
Vitest: CI-aware aliasing (no alias on CI), explicit test.dir and test.include, enable coverage, enable test.sequence.shuffle; test import changed to ecij/plugin and logLevel adjusted to warn.
Plugin API
src/index.ts
Public API now accepts `configuration?: Configuration

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nudged the configs, soft and kind,
Made defaults safe so none are blind,
Tests now know when CI takes the stage,
Aliases tidy, coverage on the page,
A little hop for cleaner build-time.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main objective: configuring CI to run tests against the built plugin, with additional minor adjustments to test configuration and coverage settings.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-against-build

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

@nstepien
nstepien marked this pull request as ready for review March 7, 2026 21:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@vitest.config.ts`:
- Around line 6-10: The alias entry for 'ecij/plugin' uses a relative path
('./src/index.ts') which can cause unpredictable resolution in tests; update the
vitest.config.ts to replace that relative string with an absolute filesystem
path resolved from the config file directory (e.g., use Node's path.resolve or
import.meta.url resolution) so the resolve.alias value is an absolute path when
isCI is false; modify the alias object for 'ecij/plugin' (in the resolve
section) to compute the absolute path at module load rather than leaving the
relative './src/index.ts'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8531a6e9-4d3a-485c-9666-10a5edd548dc

📥 Commits

Reviewing files that changed from the base of the PR and between 6c7f15c and 6f9aa77.

📒 Files selected for processing (9)
  • .gitignore
  • AGENTS.md
  • README.md
  • package.json
  • test/plugin.test.ts
  • tsconfig.base.json
  • tsconfig.test.json
  • tsconfig.tools.json
  • vitest.config.ts
💤 Files with no reviewable changes (1)
  • tsconfig.base.json

Comment thread vitest.config.ts
Comment on lines +6 to +10
resolve: {
// In CI, test files will import the built plugin to validate the published package.
// Locally, alias the plugin to the source code for easier debugging.
alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' },
},

@coderabbitai coderabbitai Bot Mar 7, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Vite 8, when configuring resolve.aliasto map a package specifier to a local source file, must the replacement be an absolute filesystem path, or is a relative path like./src/index.ts resolved correctly?

💡 Result:

In Vite 8, resolve.alias doesn’t require the replacement to be an absolute filesystem path: it may be either an absolute path or a path relative to the project root. However, Vite notes that relative alias values are used “as-is” (they are not turned into filesystem paths), so using ./src/index.ts can be surprising because it stays a literal relative specifier rather than being normalized to an absolute file path. Prefer an absolute path (e.g. fileURLToPath(new URL('./src/index.ts', import.meta.url))) when aliasing to local files. [1] [2] [3]


🏁 Script executed:

# Check the structure of the vitest.config.ts file
head -20 vitest.config.ts

# Verify the file structure
ls -la src/index.ts 2>/dev/null || echo "src/index.ts not found"

# Check if test/plugin.test.ts exists and examine its imports
ls -la test/plugin.test.ts 2>/dev/null || echo "test/plugin.test.ts not found"

Repository: nstepien/ecij

Length of output: 730


🏁 Script executed:

# Get full context of vitest.config.ts
cat -n vitest.config.ts | head -30

Repository: nstepien/ecij

Length of output: 761


🏁 Script executed:

# Check how test/plugin.test.ts imports the plugin
grep -n "ecij/plugin\|from\|import" test/plugin.test.ts | head -15

Repository: nstepien/ecij

Length of output: 362


🏁 Script executed:

# Verify the package.json to understand the package structure
cat -n package.json | head -30

Repository: nstepien/ecij

Length of output: 910


🏁 Script executed:

# See the complete exports section in package.json
sed -n '25,35p' package.json

Repository: nstepien/ecij

Length of output: 265


🏁 Script executed:

# Check what src/index.ts exports (first 50 lines to see the export structure)
head -50 src/index.ts | grep -E "^export|^import"

Repository: nstepien/ecij

Length of output: 455


Use an absolute path for the local ecij/plugin alias.

At Line 9, Vite's resolve.alias should use an absolute filesystem path rather than a relative path. Relative paths like './src/index.ts' are used as-is without normalization to absolute paths, which can cause unpredictable resolution behavior in tests. Replace with an absolute path resolved from the config file's directory.

🔧 Proposed fix
+import { fileURLToPath } from 'node:url';
 import { defineConfig } from 'vitest/config';
@@
-    alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' },
+    alias: isCI
+      ? undefined
+      : { 'ecij/plugin': fileURLToPath(new URL('./src/index.ts', import.meta.url)) },
📝 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
resolve: {
// In CI, test files will import the built plugin to validate the published package.
// Locally, alias the plugin to the source code for easier debugging.
alias: isCI ? undefined : { 'ecij/plugin': './src/index.ts' },
},
import { fileURLToPath } from 'node:url';
resolve: {
// In CI, test files will import the built plugin to validate the published package.
// Locally, alias the plugin to the source code for easier debugging.
alias: isCI
? undefined
: { 'ecij/plugin': fileURLToPath(new URL('./src/index.ts', import.meta.url)) },
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vitest.config.ts` around lines 6 - 10, The alias entry for 'ecij/plugin' uses
a relative path ('./src/index.ts') which can cause unpredictable resolution in
tests; update the vitest.config.ts to replace that relative string with an
absolute filesystem path resolved from the config file directory (e.g., use
Node's path.resolve or import.meta.url resolution) so the resolve.alias value is
an absolute path when isCI is false; modify the alias object for 'ecij/plugin'
(in the resolve section) to compute the absolute path at module load rather than
leaving the relative './src/index.ts'.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@claude is this true? Please double-check. Seems to work fine from what I've tried.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@claude claude Bot Mar 7, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude finished @nstepien's task in 3m 5s —— View job


Checking CodeRabbit's claim about relative paths in resolve.alias

  • Reading vitest.config.ts to understand the current code
  • Investigating Vite/Vitest alias resolution behavior
  • Posting findings

Short answer: CodeRabbit's concern appears to be a false positive for this specific setup.

Here's the analysis:

What CodeRabbit claims: Using './src/index.ts' (a relative path) as a resolve.alias replacement will cause "unpredictable resolution" because Vite passes it through as-is without normalizing to an absolute path.

What actually happens:

vitest.config.ts sits at the project root. When Vitest processes this config, the alias 'ecij/plugin': './src/index.ts' gets evaluated. Vite 8 (used here at 8.0.0-rc.2) uses @rollup/plugin-alias internally, which — when it encounters a relative replacement path — resolves it using path.resolve(dirname(importer), updatedId) where importer is the file that triggered the import. For test/plugin.test.ts importing ecij/plugin, this would yield <project>/test/src/index.ts, which doesn't exist.

But the tests do pass. This means one of the following is true:

  1. Vite 8 resolves the alias replacement relative to the project root (not the importer), unlike what CodeRabbit's web query suggested — which would yield <project>/src/index.ts ✓
  2. Or Vite 8 normalizes the relative path to an absolute one at config-load time before @rollup/plugin-alias processes it

Either way, your experience confirms it works correctly, and the CodeRabbit flag is a false positive here. The concern in the Vite docs about relative paths being "used as-is" applies more to edge cases (e.g., config not at project root, monorepos with cross-package aliases), not this straightforward local dev alias.

Verdict: No change needed. CodeRabbit's suggested fix (fileURLToPath(new URL('./src/index.ts', import.meta.url))) would produce the same result and is more explicit, but it's not required for correctness.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/index.ts (1)

431-432: Redundant nullish coalescing operators.

Since include and exclude are already assigned non-nullish defaults at lines 60-61, the ?? operators here will never evaluate to their right-hand side. These fallbacks are unnecessary.

Suggested simplification
       filter: {
         id: {
-          include: makeIdFiltersToMatchWithQuery(include ?? JS_TS_FILE_REGEX),
-          exclude: makeIdFiltersToMatchWithQuery(exclude ?? [NODE_MODULES_REGEX, D_TS_FILE_REGEX]),
+          include: makeIdFiltersToMatchWithQuery(include),
+          exclude: makeIdFiltersToMatchWithQuery(exclude),
         },
       },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/index.ts` around lines 431 - 432, The nullish coalescing on include and
exclude is redundant because include and exclude already have non-null defaults;
update the calls to makeIdFiltersToMatchWithQuery to pass include and exclude
directly (i.e., remove "?? JS_TS_FILE_REGEX" and "?? [NODE_MODULES_REGEX,
D_TS_FILE_REGEX]") so that include/exclude are used as-is in the calls to
makeIdFiltersToMatchWithQuery.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/index.ts`:
- Around line 431-432: The nullish coalescing on include and exclude is
redundant because include and exclude already have non-null defaults; update the
calls to makeIdFiltersToMatchWithQuery to pass include and exclude directly
(i.e., remove "?? JS_TS_FILE_REGEX" and "?? [NODE_MODULES_REGEX,
D_TS_FILE_REGEX]") so that include/exclude are used as-is in the calls to
makeIdFiltersToMatchWithQuery.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a1743d14-a274-4364-a692-78e9da0237bf

📥 Commits

Reviewing files that changed from the base of the PR and between 6f9aa77 and 44753b1.

📒 Files selected for processing (2)
  • README.md
  • src/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

@nstepien
nstepien merged commit 025d3f8 into main Mar 7, 2026
11 checks passed
@nstepien
nstepien deleted the test-against-build branch March 7, 2026 21:58
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