Skip to content

test: refactor bundler_promiseall_deadcode to use itBundled helper - #23370

Merged
Jarred-Sumner merged 1 commit into
mainfrom
claude/refactor-promiseall-deadcode-test
Oct 9, 2025
Merged

Jarred-Sumner merged 1 commit into
mainfrom
claude/refactor-promiseall-deadcode-test

Conversation

@robobun

@robobun robobun commented Oct 8, 2025

Copy link
Copy Markdown
Collaborator

Summary

Modernizes test/bundler/bundler_promiseall_deadcode.test.ts to use the itBundled test helper instead of manual temp directory creation and spawning. This makes the test more concise, maintainable, and consistent with other bundler tests.

Changes

  • Replace tempDirWithFiles + manual Bun.spawn with itBundled
  • Use files object for test fixtures instead of creating a temp directory
  • Use onAfterBundle callback for bundled output assertions
  • Use run.validate for runtime stderr validation
  • Use run.partialStdout for stdout verification
  • Preserve all original test assertions and behavior

Test Results

All 3 tests pass with identical functional behavior:

 3 pass
 0 fail
 2 snapshots, 23 expect() calls
Ran 3 tests across 1 file. [8.95s]

Verification

All original assertions are preserved:

  • ✅ Build success validation
  • ✅ Bundled output snapshots (updated paths to match itBundled format)
  • ✅ __esm and __promiseAll presence/absence checks
  • ✅ Runtime execution validation (exit code 0)
  • ✅ Runtime stderr validation (no async syntax errors)
  • ✅ Runtime stdout validation (contains expected output)

The test is now more concise (407 insertions vs 514 deletions) while maintaining full test coverage.

🤖 Generated with Claude Code

Modernizes the test to use the itBundled test helper instead of manual
temp directory creation and spawning. This makes the test more concise
and consistent with other bundler tests.

Changes:
- Replace tempDirWithFiles + manual Bun.spawn with itBundled
- Use files object for test fixtures
- Use onAfterBundle callback for bundled output assertions
- Use run.validate for runtime stderr checks
- Use run.partialStdout for stdout verification
- Preserve all original test assertions and behavior

All 3 tests pass with identical functional behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@robobun

robobun commented Oct 8, 2025 •

Copy link
Copy Markdown
Collaborator Author
Updated 4:41 AM PT - Oct 8th, 2025

❌ Your commit ab828c3d has 1 failures in Build #28513 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 23370

That installs a local version of the PR into your bun-23370 executable, so you can run:

bun-23370 --bun

@github-actions github-actions Bot added the claude label Oct 8, 2025
@coderabbitai

coderabbitai Bot commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Rewrites test/bundler/bundler_promiseall_deadcode.test.ts from a test(...) style to describe/itBundled using the expectBundled harness. Consolidates scenarios into in-memory bundled file maps with onAfterBundle assertions, updates expectations around __promiseAll/__esm, and replaces process-spawned runs with declarative bundle checks.

Changes

Cohort / File(s) Summary of changes
Bundler test migration
test/bundler/bundler_promiseall_deadcode.test.ts
Converted to describe/itBundled with expectBundled harness; inlined entry points and module initializations; added onAfterBundle assertions and inline snapshots; updated expectations for __promiseAll and __esm; removed prior path-based build/run via test(...) and Bun process spawning.

Possibly related PRs

Suggested reviewers

  • Jarred-Sumner
  • pfgithub

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description provides comprehensive details on what was changed and how tests were verified, but it does not follow the repository’s required template headings of “What does this PR do?” and “How did you verify your code works?”, instead using “Summary”, “Changes”, and other custom sections. Please update the PR description to use the specified template headings by renaming “## Summary” to “### What does this PR do?” and adding a “### How did you verify your code works?” section that summarizes the verification steps.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly states the primary change by indicating that the bundler_promiseall_deadcode test is being refactored to use the itBundled helper, which directly reflects the main change in the patch. It is concise, specific, and free of unrelated noise, enabling a reviewer to understand the essence of the PR at a glance.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d10e57 and ab828c3.

📒 Files selected for processing (1)
  • test/bundler/bundler_promiseall_deadcode.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
test/**

📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)

Place all tests under the test/ directory

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
test/bundler/**/*

📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)

Place bundler/transpiler/CSS/bun build tests under test/bundler/

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
test/**/*.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/writing-tests.mdc)

test/**/*.{js,ts}: Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test
Prefer data-driven tests (e.g., test.each) to reduce boilerplate
Use shared utilities from test/harness.ts where applicable

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
test/**/*.test.ts

📄 CodeRabbit inference engine (test/CLAUDE.md)

test/**/*.test.ts: Name test files *.test.ts and use bun:test
Do not write flaky tests: never wait for arbitrary time; wait for conditions instead
Never hardcode port numbers in tests; use port: 0 to get a random port
When spawning Bun in tests, use bunExe() and bunEnv from harness
Prefer async/await in tests; for a single callback, use Promise.withResolvers()
Do not set explicit test timeouts; rely on Bun’s built-in timeouts
Use tempDir/tempDirWithFiles from harness for temporary files and directories in tests
For large/repetitive strings in tests, prefer Buffer.alloc(count, fill).toString() over "A".repeat(count)
Import common test utilities from harness (e.g., bunExe, bunEnv, tempDirWithFiles, tmpdirSync, platform checks, GC helpers)
In error tests, assert non-zero exit codes for failing processes and use toThrow for synchronous errors
Use describe blocks for grouping, describe.each for parameterized tests, snapshots with toMatchSnapshot, and lifecycle hooks (beforeAll, beforeEach, afterEach); track resources for cleanup in afterEach
Use using/await using with Bun resources (e.g., Bun.listen/connect/spawn/serve) to ensure cleanup in tests

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
test/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

test/**/*.test.{ts,tsx}: Test files must live under test/ and end with .test.ts or .test.tsx
In tests, always use port: 0; do not hardcode ports or roll your own random port
Prefer normalizeBunSnapshot for snapshotting test output instead of asserting raw strings
Do not write tests that assert absence of crashes (e.g., 'no panic' or 'no uncaught exception')
Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests
Avoid shell commands like find or grep in tests; use Bun’s Glob and built-in tools instead
Prefer running tests via bun bd test and use provided harness utilities (bunEnv, bunExe, tempDir)
Use Bun.spawn with proper stdio handling and await proc.exited in process-spawning tests

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
test/bundler/**

📄 CodeRabbit inference engine (CLAUDE.md)

Place bundler/transpiler tests under test/bundler/

Files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: oven-sh/bun#0
File: test/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:10:13.486Z
Learning: Applies to test/**/*.test.ts : Use `describe` blocks for grouping, `describe.each` for parameterized tests, snapshots with `toMatchSnapshot`, and lifecycle hooks (`beforeAll`, `beforeEach`, `afterEach`); track resources for cleanup in `afterEach`
Learnt from: CR
PR: oven-sh/bun#0
File: .cursor/rules/dev-server-tests.mdc:0-0
Timestamp: 2025-08-30T00:09:39.100Z
Learning: Applies to test/bake/dev/bundle.test.ts : bundle.test.ts should contain DevServer-specific bundling tests
Learnt from: CR
PR: oven-sh/bun#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-04T09:51:30.294Z
Learning: Applies to test/**/*.test.{ts,tsx} : Prefer running tests via bun bd test <file> and use provided harness utilities (bunEnv, bunExe, tempDir)
Learnt from: CR
PR: oven-sh/bun#0
File: .cursor/rules/writing-tests.mdc:0-0
Timestamp: 2025-08-30T00:12:56.803Z
Learning: Applies to test/**/*.{js,ts} : Use shared utilities from test/harness.ts where applicable
Learnt from: CR
PR: oven-sh/bun#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-04T09:51:30.294Z
Learning: Applies to test/bundler/** : Place bundler/transpiler tests under test/bundler/
📚 Learning: 2025-08-30T00:09:39.100Z
Learnt from: CR
PR: oven-sh/bun#0
File: .cursor/rules/dev-server-tests.mdc:0-0
Timestamp: 2025-08-30T00:09:39.100Z
Learning: Applies to test/bake/dev/bundle.test.ts : bundle.test.ts should contain DevServer-specific bundling tests

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
📚 Learning: 2025-10-04T09:51:30.294Z
Learnt from: CR
PR: oven-sh/bun#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-04T09:51:30.294Z
Learning: Applies to test/**/*.test.{ts,tsx} : Prefer running tests via bun bd test <file> and use provided harness utilities (bunEnv, bunExe, tempDir)

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
📚 Learning: 2025-09-03T17:10:13.486Z
Learnt from: CR
PR: oven-sh/bun#0
File: test/CLAUDE.md:0-0
Timestamp: 2025-09-03T17:10:13.486Z
Learning: Applies to test/**/*.test.ts : Use `describe` blocks for grouping, `describe.each` for parameterized tests, snapshots with `toMatchSnapshot`, and lifecycle hooks (`beforeAll`, `beforeEach`, `afterEach`); track resources for cleanup in `afterEach`

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
📚 Learning: 2025-10-04T09:51:30.294Z
Learnt from: CR
PR: oven-sh/bun#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-04T09:51:30.294Z
Learning: Applies to test/**/*.test.{ts,tsx} : Use Bun’s Jest-compatible runner (import { test, expect } from "bun:test") for tests

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
📚 Learning: 2025-08-30T00:12:56.803Z
Learnt from: CR
PR: oven-sh/bun#0
File: .cursor/rules/writing-tests.mdc:0-0
Timestamp: 2025-08-30T00:12:56.803Z
Learning: Applies to test/**/*.{js,ts} : Write tests in JavaScript or TypeScript using Bun’s Jest-style APIs (test, describe, expect) and run with bun test

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
📚 Learning: 2025-08-30T00:09:39.100Z
Learnt from: CR
PR: oven-sh/bun#0
File: .cursor/rules/dev-server-tests.mdc:0-0
Timestamp: 2025-08-30T00:09:39.100Z
Learning: Applies to test/bake/dev/esm.test.ts : esm.test.ts should cover ESM feature behavior in development mode

Applied to files:

  • test/bundler/bundler_promiseall_deadcode.test.ts
🧬 Code graph analysis (1)
test/bundler/bundler_promiseall_deadcode.test.ts (1)
test/bundler/expectBundled.ts (1)
  • itBundled (1734-1768)

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

@Jarred-Sumner
Jarred-Sumner merged commit 6875cc3 into main Oct 9, 2025
61 of 62 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the claude/refactor-promiseall-deadcode-test branch October 9, 2025 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants