`examples` for property tests

Đang mở
#10,971 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ệ
typescript
Lĩnh vực
testing

Hướng nghiên cứu

Start by locating CheckOptions and the implementations of it.prop and it.effect.prop, then trace how generated cases are checked. Add support for running supplied examples before generated cases, and consider how named examples appear in failures. Done when examples are checked by all three APIs and the behavior is covered by tests; the issue names no files or tests, so first map the relevant test entry points.

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

Mô tả

enhancement
What is the problem this feature would solve?

fast-check's examples parameter runs known inputs before the generated ones. When migrating property tests from fast-check to Arbitrary and @effect/vitest's it.prop, there's no equivalent in CheckOptions or the it.prop options.

We use examples heavily (several hundred tests) for edge cases and regression inputs that sit alongside the generated ones. Without it, each one becomes a separate it.each sharing the property's assertion:

const property = (events: ReadonlyArray<Event>, id: Id) => {
  expect(foldState(events, id)).toStrictEqual(new NotStarted())
}

it.prop("generated", [Schema.Array(Event), Id], ([events, id]) => property(events, id))

it.each([
  ["no events", [], id1],
  ["events for another review", [started], id2],
])("%s", (_name, events, id) => property(events, id))
What is the feature you are proposing to solve the problem?

An examples option on CheckOptions, and so on it.prop and it.effect.prop, that checks the given inputs before generated ones:

it.prop("not started", [Schema.Array(Event), Id], ([events, id]) => property(events, id), {
  arbitrary: {
    examples: [
      [[], id1],
      [[started], id2],
    ],
  },
})

Ideally an example could have a name, shown in the output when it fails, for example { name: "events for another review", value: [[started], id2] }. That would improve on fast-check, where we keep the names in comments.

What alternatives have you considered?

it.each alongside each property, as above. It works but doubles the boilerplate. It also separates the examples from the property they belong to, so they aren't shrunk or replayed with it.

Ngôn ngữ chính
TypeScript
Star
16.7k
Fork
808
Merge trung bình
21 giờ 22 phút
Pull request đã merge (30 ngày)
486

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 Effect-TS/effect

Tất cả issue của Effect-TS/effect

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.