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

test: user-subscription specs fail outside UTC, so the pre-commit hook cannot pass

Đang mở Phù hợp với người mới
#971 1 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

@tejasvasingh2004 đang làm issue này rồi.

Từ ngày 25/10/2026.

Đánh giá

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

Hướng nghiên cứu

Bắt đầu với test/unit/repositories/user-subscription-repository.spec.ts và chạy nó trong cả TZ=UTC lẫn TZ=America/Toronto để tái hiện năm lỗi. Theo dõi cách các spec tạo ngày biên và cách trình điều khiển truy vấn thể hiện chúng; làm cho ranh giới không phụ thuộc vào múi giờ cục bộ và xác nhận giá trị được truyền cho trình điều khiển. Hoàn tất khi cả 17 spec đều chạy thành công ở cả hai múi giờ.

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

Mô tả

test/unit/repositories/user-subscription-repository.spec.ts passes under TZ=UTC and fails under any negative-offset zone, so the pre-commit hook cannot pass for anyone running outside UTC — including this development environment, which is America/Toronto.

$ TZ=UTC npx mocha test/unit/repositories/user-subscription-repository.spec.ts
  17 passing

$ TZ=America/Toronto npx mocha test/unit/repositories/user-subscription-repository.spec.ts
  12 passing, 5 failing
     AssertionError: expected 'select * from "user_subscriptions" wh…' to include '"current_period_end" <= '2026-01-31'

All five are the same defect: the specs build a boundary date and assert the literal 2026-01-31 appears in the generated SQL, but the driver renders the value in the local zone, so at UTC-5 the SQL carries a different instant. The two updateIfCurrent failures are the same cause in the IS NOT DISTINCT FROM clause.

CI is UTC, so main is green and the problem is invisible there. It only appears locally, as a pre-commit failure that looks like the change under test is broken.

Fix direction: make the boundary explicit rather than ambient — construct the dates in UTC (or set process.env.TZ = 'UTC' before the module under test is imported, which Node honours for later Date work) and assert on the value the driver is given, not on a date literal that only matches in UTC.

Found while committing an unrelated compose fix (#929).

Ngôn ngữ chính
TypeScript
Star
829
Fork
234
Merge trung bình
17 giờ 6 phút
Pull request đã merge (30 ngày)
92

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

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 cameri/nostream

Tất cả issue của cameri/nostream

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.