Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉 適合新手
#971 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@tejasvasingh2004 已經在處理了。

開始於 2026年10月25日。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
testing

研究方向

從 test/unit/repositories/user-subscription-repository.spec.ts 開始,分別在 TZ=UTC 和 TZ=America/Toronto 下執行,以重現五個失敗。追蹤 specs 如何建構邊界日期,以及查詢驅動程式如何呈現這些日期;使邊界不受本地時區影響,並斷言傳遞給驅動程式的值。兩個時區下的 17 個 specs 全部通過後即完成。

由索引模型根據 Issue 內容生成。

描述

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).

主要語言
TypeScript
星號
829
分支
234
平均合併
17 小時 6 分鐘
30 天內合併 PR
92

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

cameri/nostream 的其他 Issue

查看 cameri/nostream 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。