Skip to content

test: add type tests for public exports#75

Merged
chenjiahan merged 1 commit into
mainfrom
chenjiahan/test-type-tests
Jul 22, 2026
Merged

test: add type tests for public exports#75
chenjiahan merged 1 commit into
mainfrom
chenjiahan/test-type-tests

Conversation

@chenjiahan

Copy link
Copy Markdown
Member

Summary

This PR adds type-level coverage for Rstack's public entry points under Bundler and NodeNext module resolution, while strictly checking the Rsbuild preset declarations exposed through rstack/types.

It also consolidates package tests under packages/rstack/tests and updates the Rstest and lint configuration paths.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: a2937d5
Status: ✅  Deploy successful!
Preview URL: https://4031148c.rstack-cli.pages.dev
Branch Preview URL: https://chenjiahan-test-type-tests.rstack-cli.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4bd3d765-f0dd-4d6d-8456-31308499f655

📥 Commits

Reviewing files that changed from the base of the PR and between 2207bc4 and a2937d5.

📒 Files selected for processing (52)
  • packages/rstack/rstack.config.ts
  • packages/rstack/tests/cli/specify-config/custom.config.ts
  • packages/rstack/tests/cli/specify-config/index.test.ts
  • packages/rstack/tests/cli/specify-config/src/index.js
  • packages/rstack/tests/cli/staged/index.test.ts
  • packages/rstack/tests/config/define-app-lib/fixture.ts
  • packages/rstack/tests/config/define-app-lib/index.test.ts
  • packages/rstack/tests/config/define-app-lib/rstack.config.ts
  • packages/rstack/tests/config/define-app/index.test.ts
  • packages/rstack/tests/config/define-app/rstack.config.ts
  • packages/rstack/tests/config/define-app/src/index.js
  • packages/rstack/tests/config/define-doc/docs/index.md
  • packages/rstack/tests/config/define-doc/index.test.ts
  • packages/rstack/tests/config/define-doc/rstack.config.ts
  • packages/rstack/tests/config/define-lib/index.test.ts
  • packages/rstack/tests/config/define-lib/package.json
  • packages/rstack/tests/config/define-lib/rstack.config.ts
  • packages/rstack/tests/config/define-lib/src/index.js
  • packages/rstack/tests/config/define-lint/index.test.ts
  • packages/rstack/tests/config/define-lint/rstack.config.ts
  • packages/rstack/tests/config/define-lint/src/index.js
  • packages/rstack/tests/config/define-test-projects-app/custom.ts
  • packages/rstack/tests/config/define-test-projects-app/first.ts
  • packages/rstack/tests/config/define-test-projects-app/index.test.ts
  • packages/rstack/tests/config/define-test-projects-app/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-app/second.ts
  • packages/rstack/tests/config/define-test-projects-lib/first.ts
  • packages/rstack/tests/config/define-test-projects-lib/index.test.ts
  • packages/rstack/tests/config/define-test-projects-lib/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-lib/second.ts
  • packages/rstack/tests/config/load-state/index.test.ts
  • packages/rstack/tests/config/load-state/rstack.config.ts
  • packages/rstack/tests/config/reload-app-config/index.test.ts
  • packages/rstack/tests/config/reload-app-config/src/index.js
  • packages/rstack/tests/exports/app-subpath/index.test.ts
  • packages/rstack/tests/exports/lib-subpath/index.test.ts
  • packages/rstack/tests/exports/lint-subpath/index.test.ts
  • packages/rstack/tests/exports/test-subpath/index.test.ts
  • packages/rstack/tests/helpers/cli.ts
  • packages/rstack/tests/helpers/cliTest.ts
  • packages/rstack/tests/helpers/constants.ts
  • packages/rstack/tests/helpers/index.ts
  • packages/rstack/tests/helpers/logs.ts
  • packages/rstack/tests/tsconfig.json
  • packages/rstack/tests/types/core-types/index.ts
  • packages/rstack/tests/types/core-types/tsconfig.json
  • packages/rstack/tests/types/resolution-bundler/index.ts
  • packages/rstack/tests/types/resolution-bundler/tsconfig.json
  • packages/rstack/tests/types/resolution-nodenext/index.ts
  • packages/rstack/tests/types/resolution-nodenext/tsconfig.json
  • packages/rstack/tests/types/tsconfig.json
  • rstack.config.ts

📝 Walkthrough

Walkthrough

Updates test TypeScript paths and lint project references for the tests layout. Adds CLI coverage for custom configs and staged options, configuration tests for app, lib, doc, lint, inheritance, reload, and load-state behavior, shared CLI/logging fixtures, type-resolution fixtures, and runtime checks for rstack subpath exports.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding type tests for public exports.
Description check ✅ Passed The description matches the PR scope, covering type-level coverage and test/lint path updates.
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 chenjiahan/test-type-tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
packages/rstack/tests/config/define-lib/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/rstack/tests/tsconfig.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

packages/rstack/tests/types/core-types/tsconfig.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

  • 3 others

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

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/rstack/tests/config/define-lib/index.test.ts`:
- Around line 6-14: Update both test cases in
packages/rstack/tests/config/define-lib/index.test.ts (lines 6-14) and
packages/rstack/tests/config/define-doc/index.test.ts (lines 6-14) to wrap the
build, file lookup, and assertions in try/finally blocks, removing each prepared
distPath in finally as demonstrated by define-app/index.test.ts.

In `@packages/rstack/tests/exports/lint-subpath/index.test.ts`:
- Around line 8-10: Replace the ineffective typeof truthiness assertion with an
exact function-type assertion in the commonLintMethods loop in
packages/rstack/tests/exports/lint-subpath/index.test.ts:8-10. Apply the same
change to the corresponding test API loop in
packages/rstack/tests/exports/test-subpath/index.test.ts:8-10, while retaining
the existing toHaveProperty checks.

In `@packages/rstack/tests/helpers/cli.ts`:
- Line 28: Update the synchronous CLI invocation around execSync to invoke the
script through Node and quote RSTACK_BIN_PATH, matching the approach used by
execCliAsync so repository paths containing spaces are handled correctly.
🪄 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 Plus

Run ID: 4bd3d765-f0dd-4d6d-8456-31308499f655

📥 Commits

Reviewing files that changed from the base of the PR and between 2207bc4 and a2937d5.

📒 Files selected for processing (52)
  • packages/rstack/rstack.config.ts
  • packages/rstack/tests/cli/specify-config/custom.config.ts
  • packages/rstack/tests/cli/specify-config/index.test.ts
  • packages/rstack/tests/cli/specify-config/src/index.js
  • packages/rstack/tests/cli/staged/index.test.ts
  • packages/rstack/tests/config/define-app-lib/fixture.ts
  • packages/rstack/tests/config/define-app-lib/index.test.ts
  • packages/rstack/tests/config/define-app-lib/rstack.config.ts
  • packages/rstack/tests/config/define-app/index.test.ts
  • packages/rstack/tests/config/define-app/rstack.config.ts
  • packages/rstack/tests/config/define-app/src/index.js
  • packages/rstack/tests/config/define-doc/docs/index.md
  • packages/rstack/tests/config/define-doc/index.test.ts
  • packages/rstack/tests/config/define-doc/rstack.config.ts
  • packages/rstack/tests/config/define-lib/index.test.ts
  • packages/rstack/tests/config/define-lib/package.json
  • packages/rstack/tests/config/define-lib/rstack.config.ts
  • packages/rstack/tests/config/define-lib/src/index.js
  • packages/rstack/tests/config/define-lint/index.test.ts
  • packages/rstack/tests/config/define-lint/rstack.config.ts
  • packages/rstack/tests/config/define-lint/src/index.js
  • packages/rstack/tests/config/define-test-projects-app/custom.ts
  • packages/rstack/tests/config/define-test-projects-app/first.ts
  • packages/rstack/tests/config/define-test-projects-app/index.test.ts
  • packages/rstack/tests/config/define-test-projects-app/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-app/second.ts
  • packages/rstack/tests/config/define-test-projects-lib/first.ts
  • packages/rstack/tests/config/define-test-projects-lib/index.test.ts
  • packages/rstack/tests/config/define-test-projects-lib/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-lib/second.ts
  • packages/rstack/tests/config/load-state/index.test.ts
  • packages/rstack/tests/config/load-state/rstack.config.ts
  • packages/rstack/tests/config/reload-app-config/index.test.ts
  • packages/rstack/tests/config/reload-app-config/src/index.js
  • packages/rstack/tests/exports/app-subpath/index.test.ts
  • packages/rstack/tests/exports/lib-subpath/index.test.ts
  • packages/rstack/tests/exports/lint-subpath/index.test.ts
  • packages/rstack/tests/exports/test-subpath/index.test.ts
  • packages/rstack/tests/helpers/cli.ts
  • packages/rstack/tests/helpers/cliTest.ts
  • packages/rstack/tests/helpers/constants.ts
  • packages/rstack/tests/helpers/index.ts
  • packages/rstack/tests/helpers/logs.ts
  • packages/rstack/tests/tsconfig.json
  • packages/rstack/tests/types/core-types/index.ts
  • packages/rstack/tests/types/core-types/tsconfig.json
  • packages/rstack/tests/types/resolution-bundler/index.ts
  • packages/rstack/tests/types/resolution-bundler/tsconfig.json
  • packages/rstack/tests/types/resolution-nodenext/index.ts
  • packages/rstack/tests/types/resolution-nodenext/tsconfig.json
  • packages/rstack/tests/types/tsconfig.json
  • rstack.config.ts

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

🤖 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/rstack/tests/config/define-lib/index.test.ts`:
- Around line 6-14: Update both test cases in
packages/rstack/tests/config/define-lib/index.test.ts (lines 6-14) and
packages/rstack/tests/config/define-doc/index.test.ts (lines 6-14) to wrap the
build, file lookup, and assertions in try/finally blocks, removing each prepared
distPath in finally as demonstrated by define-app/index.test.ts.

In `@packages/rstack/tests/exports/lint-subpath/index.test.ts`:
- Around line 8-10: Replace the ineffective typeof truthiness assertion with an
exact function-type assertion in the commonLintMethods loop in
packages/rstack/tests/exports/lint-subpath/index.test.ts:8-10. Apply the same
change to the corresponding test API loop in
packages/rstack/tests/exports/test-subpath/index.test.ts:8-10, while retaining
the existing toHaveProperty checks.

In `@packages/rstack/tests/helpers/cli.ts`:
- Line 28: Update the synchronous CLI invocation around execSync to invoke the
script through Node and quote RSTACK_BIN_PATH, matching the approach used by
execCliAsync so repository paths containing spaces are handled correctly.
🪄 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 Plus

Run ID: 4bd3d765-f0dd-4d6d-8456-31308499f655

📥 Commits

Reviewing files that changed from the base of the PR and between 2207bc4 and a2937d5.

📒 Files selected for processing (52)
  • packages/rstack/rstack.config.ts
  • packages/rstack/tests/cli/specify-config/custom.config.ts
  • packages/rstack/tests/cli/specify-config/index.test.ts
  • packages/rstack/tests/cli/specify-config/src/index.js
  • packages/rstack/tests/cli/staged/index.test.ts
  • packages/rstack/tests/config/define-app-lib/fixture.ts
  • packages/rstack/tests/config/define-app-lib/index.test.ts
  • packages/rstack/tests/config/define-app-lib/rstack.config.ts
  • packages/rstack/tests/config/define-app/index.test.ts
  • packages/rstack/tests/config/define-app/rstack.config.ts
  • packages/rstack/tests/config/define-app/src/index.js
  • packages/rstack/tests/config/define-doc/docs/index.md
  • packages/rstack/tests/config/define-doc/index.test.ts
  • packages/rstack/tests/config/define-doc/rstack.config.ts
  • packages/rstack/tests/config/define-lib/index.test.ts
  • packages/rstack/tests/config/define-lib/package.json
  • packages/rstack/tests/config/define-lib/rstack.config.ts
  • packages/rstack/tests/config/define-lib/src/index.js
  • packages/rstack/tests/config/define-lint/index.test.ts
  • packages/rstack/tests/config/define-lint/rstack.config.ts
  • packages/rstack/tests/config/define-lint/src/index.js
  • packages/rstack/tests/config/define-test-projects-app/custom.ts
  • packages/rstack/tests/config/define-test-projects-app/first.ts
  • packages/rstack/tests/config/define-test-projects-app/index.test.ts
  • packages/rstack/tests/config/define-test-projects-app/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-app/second.ts
  • packages/rstack/tests/config/define-test-projects-lib/first.ts
  • packages/rstack/tests/config/define-test-projects-lib/index.test.ts
  • packages/rstack/tests/config/define-test-projects-lib/rstack.config.ts
  • packages/rstack/tests/config/define-test-projects-lib/second.ts
  • packages/rstack/tests/config/load-state/index.test.ts
  • packages/rstack/tests/config/load-state/rstack.config.ts
  • packages/rstack/tests/config/reload-app-config/index.test.ts
  • packages/rstack/tests/config/reload-app-config/src/index.js
  • packages/rstack/tests/exports/app-subpath/index.test.ts
  • packages/rstack/tests/exports/lib-subpath/index.test.ts
  • packages/rstack/tests/exports/lint-subpath/index.test.ts
  • packages/rstack/tests/exports/test-subpath/index.test.ts
  • packages/rstack/tests/helpers/cli.ts
  • packages/rstack/tests/helpers/cliTest.ts
  • packages/rstack/tests/helpers/constants.ts
  • packages/rstack/tests/helpers/index.ts
  • packages/rstack/tests/helpers/logs.ts
  • packages/rstack/tests/tsconfig.json
  • packages/rstack/tests/types/core-types/index.ts
  • packages/rstack/tests/types/core-types/tsconfig.json
  • packages/rstack/tests/types/resolution-bundler/index.ts
  • packages/rstack/tests/types/resolution-bundler/tsconfig.json
  • packages/rstack/tests/types/resolution-nodenext/index.ts
  • packages/rstack/tests/types/resolution-nodenext/tsconfig.json
  • packages/rstack/tests/types/tsconfig.json
  • rstack.config.ts
🛑 Comments failed to post (3)
packages/rstack/tests/config/define-lib/index.test.ts (1)

6-14: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the relevant tests
git ls-files 'packages/rstack/tests/**/index.test.ts' | sed -n '1,200p'

echo '--- define-lib ---'
cat -n packages/rstack/tests/config/define-lib/index.test.ts

echo '--- define-doc ---'
cat -n packages/rstack/tests/config/define-doc/index.test.ts

echo '--- app test candidates ---'
rg -n "finally|remove|cleanup|prepareDist" packages/rstack/tests -g 'index.test.ts' -A 4 -B 4

Repository: rstackjs/rstack-cli

Length of output: 8248


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- packages/rstack/tests/config/define-lib/index.test.ts ---'
sed -n '1,220p' packages/rstack/tests/config/define-lib/index.test.ts

echo '--- packages/rstack/tests/config/define-doc/index.test.ts ---'
sed -n '1,220p' packages/rstack/tests/config/define-doc/index.test.ts

echo '--- search for cleanup in nearby tests ---'
rg -n "finally|removeSync|rmSync|cleanup|prepareDist" packages/rstack/tests -g 'index.test.ts'

Repository: rstackjs/rstack-cli

Length of output: 2664


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the fixture/helper implementation for prepareDist and any cleanup helpers.
rg -n "prepareDist" packages -g '*.ts' -A 4 -B 4
rg -n "rmSync|removeSync|mkdtemp|tmpdir|prepareDist" packages -g '*.ts' -A 3 -B 3

Repository: rstackjs/rstack-cli

Length of output: 12630


Clean up the prepared dist directories in these config tests. Both tests leave their temporary build output behind on success or failure; wrap the assertions in try/finally and remove distPath afterward, like packages/rstack/tests/config/define-app/index.test.ts.

📍 Affects 2 files
  • packages/rstack/tests/config/define-lib/index.test.ts#L6-L14 (this comment)
  • packages/rstack/tests/config/define-doc/index.test.ts#L6-L14
🤖 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/rstack/tests/config/define-lib/index.test.ts` around lines 6 - 14,
Update both test cases in packages/rstack/tests/config/define-lib/index.test.ts
(lines 6-14) and packages/rstack/tests/config/define-doc/index.test.ts (lines
6-14) to wrap the build, file lookup, and assertions in try/finally blocks,
removing each prepared distPath in finally as demonstrated by
define-app/index.test.ts.
packages/rstack/tests/exports/lint-subpath/index.test.ts (1)

8-10: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Make the callable-export checks meaningful.

Both tests apply toBeTruthy() to typeof, which is truthy even for "undefined". Assert toBe('function') at both sites.

  • packages/rstack/tests/exports/lint-subpath/index.test.ts#L8-L10: require each lint API to have function type.
  • packages/rstack/tests/exports/test-subpath/index.test.ts#L8-L10: require each test API to have function type.
📍 Affects 2 files
  • packages/rstack/tests/exports/lint-subpath/index.test.ts#L8-L10 (this comment)
  • packages/rstack/tests/exports/test-subpath/index.test.ts#L8-L10
🤖 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/rstack/tests/exports/lint-subpath/index.test.ts` around lines 8 -
10, Replace the ineffective typeof truthiness assertion with an exact
function-type assertion in the commonLintMethods loop in
packages/rstack/tests/exports/lint-subpath/index.test.ts:8-10. Apply the same
change to the corresponding test API loop in
packages/rstack/tests/exports/test-subpath/index.test.ts:8-10, while retaining
the existing toHaveProperty checks.
packages/rstack/tests/helpers/cli.ts (1)

28-28: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Quote and invoke the CLI script through Node.

Line 28 splits RSTACK_BIN_PATH when the repository path contains spaces. Match execCliAsync by invoking node and quoting the script path.

Proposed fix
-    const output = execSync(`${RSTACK_BIN_PATH} ${command}`, {
+    const output = execSync(`node "${RSTACK_BIN_PATH}" ${command}`, {
📝 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.

    const output = execSync(`node "${RSTACK_BIN_PATH}" ${command}`, {
🧰 Tools
🪛 ast-grep (0.44.1)

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { type ExecSyncOptions, execSync } from 'node:child_process';
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

🪛 OpenGrep (1.25.0)

[ERROR] 28-35: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)

🤖 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/rstack/tests/helpers/cli.ts` at line 28, Update the synchronous CLI
invocation around execSync to invoke the script through Node and quote
RSTACK_BIN_PATH, matching the approach used by execCliAsync so repository paths
containing spaces are handled correctly.

@chenjiahan
chenjiahan merged commit 2f6e3f6 into main Jul 22, 2026
4 checks passed
@chenjiahan
chenjiahan deleted the chenjiahan/test-type-tests branch July 22, 2026 14:02
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