Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Let a configured container be cloned and customised with functions

Đang mở
#1,556 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
docker, node.js, typescript
Lĩnh vực
testing, tooling

Hướng nghiên cứu

Start with the dependency, issue #1520, since this issue says clone() depends on its builder state being made copyable. Then read packages/testcontainers/src/generic-container/generic-container.ts and packages/testcontainers/src/test-container.ts to see how builder state and subclass state are handled. Done means clone() returns an independent builder of the same class and with(fn) applies a customizer in the chain; run the relevant tests in the test-container file.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement minor

What happens

A configured container cannot be used as a template. Builders are mutable and every with* method returns the same object:

const base = new GenericContainer(image).withEnvironment({ LOG_LEVEL: "debug" });
const a = base.withName("a");
const b = base.withName("b");
// a, b and base are one object, named "b"

Shared configuration therefore lives in factory functions, and a reusable piece of configuration has to be applied outside the chain:

const container = new PostgreSqlContainer(image).withDatabase("orders");
applyTracing(container);
await container.start();

Expected

  • clone() returns an independent copy of the builder, of the same class.
  • with(fn) applies a function inside the chain:
const withTracing = <T extends GenericContainer>(container: T) => container.withEnvironment({ OTEL_ENABLED: "true" });

await new PostgreSqlContainer(image).withDatabase("orders").with(withTracing).start();

Where

packages/testcontainers/src/generic-container/generic-container.ts and packages/testcontainers/src/test-container.ts.

Notes

  • Go models reusable configuration as ContainerCustomizer values passed to Run.
  • clone() needs the builder's state to be copyable in one place, including what subclasses add.

Dependencies

  • Blocked by #1520: clone() needs the builder state to be copyable, which is what that fix introduces.
Ngôn ngữ chính
TypeScript
Star
2.6k
Fork
277
Merge trung bình
1 ngày 53 phút
Pull request đã merge (30 ngày)
58

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của testcontainers/testcontainers-node

Tất cả issue của testcontainers/testcontainers-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.