nodejs / nodejs/node

Add `partialDeepEqual()` in strict assertion mode

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

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

feature request never-stale
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

What is the problem this feature will solve?

I use strict assertion mode in my tests:

import assert from "node:assert/strict";

assert.equal("...", "...");
assert.deepEqual({ "..." }, { "..." });
assert.partialDeepEqual({ "..." }, { "..." });

But the partialDeepEqual() doesn't exist. You have to use partialDeepStrictEqual() that has the word Strict in its name, whereas the other methods do not.

What is the feature you are proposing to solve the problem?

The "node:assert/strict" module should re-export partialDeepStrictEqual() with the name partialDeepEqual() so that function names are consistent in strict assertion mode.

Additional information

The partialDeepStrictEqual() function was added with https://github.com/nodejs/node/pull/54630. I couldn't find any references to the terms strict assertion mode.

"Re-export" takes place in two locations:

I don't think adding the following two lines is enough?

// if (options.strict) { 
this.partialDeepEqual = this.partialDeepStrictEqual; 

// assert.strict = ObjectAssign(strict, assert, { 
partialDeepEqual: assert.partialDeepStrictEqual, 

Because partialDeepEqual() doesn't exist in legacy assertion mode. So we need to manage the fact that the Assert type will be different between the two modes.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

Hướng nghiên cứu

Bắt đầu trong lib/assert.js, tại hai vị trí export được liên kết quanh các dòng 126-131 và 894-899, rồi kiểm tra cách các chế độ assertion strict và legacy cung cấp kiểu Assert. Thêm alias cho chế độ strict mà không thêm vào chế độ legacy, sau đó xác minh rằng cả hai dạng import đều cung cấp partialDeepEqual, trong khi partialDeepStrictEqual vẫn khả dụng.

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

Đánh giá

Công nghệ
javascript
Lĩnh vực
api
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
68/100

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.