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

Testing component with Context

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

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
elixir
Lĩnh vực
backend, testing

Hướng nghiên cứu

Start with the Wrapper component's from_context: :navigation declaration and the render_surface and compile_surface calls shown in the issue. Determine how context should be supplied during component tests, then verify that rendering Wrapper with navigation items no longer produces a nil-list error.

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

Mô tả

Hi,

I am trying to perform a test on a component that retrieves a value from the context and I can't find a proper way to achieve it.

Say I have the following Wrapper live component:

data items, :list, from_context: :navigation

def render(assigns) do
  ~F"""
    <div>
      <Navigation items={@items} />
    </div>
  """
end

I tried to pass the items through the use_config macro like this:

using_config Wrapper, items: [1, 2, 3] do
  html = render_surface do
    ~F"""
      <Wrapper id="navigation" />
    """
  end
end

but it throws a runtime error saying items is nil (not a valid list).

Is there a way to provide the render_surface with a context? Or perhaps to use something other than render_surface, say compile_surface (I tried that macro as well to no avail).

Ngôn ngữ chính
Elixir
Star
2.1k
Fork
146
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 surface-ui/surface

Tất cả issue của surface-ui/surface

Issue tương tự

Thêm issue về Elixir

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.