-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Problem Description
The browser tests are importing testcontainers' internal build files which are not part of the public API and have broken multiple times during version updates:
// Current fragile approach
import {HttpWaitStrategy} from "testcontainers/build/wait-strategies/http-wait-strategy.js";
Issues:
- Internal path
testcontainers/build/…/http-wait-strategy.js
is not part of public API - Already broke twice between versions 10.13 → 10.25
- Requires adding
.js
extensions for ESM compatibility workarounds - Fragile to future testcontainers releases
- Type safety concerns with internal imports
Affected Files:
tests/browser/tests/codeserver.spec.ts
(lines 5-7, 45-47)
Solution
Replace internal imports with the public Wait builder API:
-import {HttpWaitStrategy} from "testcontainers/build/wait-strategies/http-wait-strategy.js";
+import { Wait } from "testcontainers";
// In container setup:
- .withWaitStrategy(new HttpWaitStrategy('/', 8787, {abortOnContainerExit: true}))
+ .withWaitStrategy(
+ Wait.forHttp('/')
+ .forPort(8787)
+ .withStartupTimeout(10 * 60 * 1000)
+ )
Benefits:
- Uses stable public API
- Survives future testcontainers releases
- Maintains type safety
- Cleaner, more readable code
- No ESM extension workarounds needed
Acceptance Criteria
- Replace HttpWaitStrategy import with Wait import in
tests/browser/tests/codeserver.spec.ts
- Update container wait strategy implementation to use Wait.forHttp() builder
- Verify tests still pass with the new implementation
- Apply fix to both 2024b and main branches
- Ensure timeout behavior remains equivalent (10 minute startup timeout)
- Confirm no other internal testcontainers imports exist in the codebase
Implementation Notes
The Wait.forHttp()
builder provides the same functionality as HttpWaitStrategy
but through the stable public API. The timeout should be configured using .withStartupTimeout()
to maintain the current 10-minute container startup timeout.
Context
- Source: PR [2024b] NO-JIRA: tests(browser/): update dependencies in
pnpm-lock.yaml
#1426 review comment - Reporter: @jiridanek
- Related: Testcontainers version upgrade from 10.13.2 to 10.25.0
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
📋 Backlog