Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#971 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
78/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
testing

Direção de pesquisa

Comece por test/unit/repositories/user-subscription-repository.spec.ts e execute-o com TZ=UTC e TZ=America/Toronto para reproduzir as cinco falhas. Acompanhe como os specs constroem as datas-limite e como o driver de consultas as representa; torne o limite independente do fuso horário local e verifique o valor passado ao driver. O trabalho estará concluído quando todos os 17 specs passarem nos dois fusos.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
829
Forks
234
Merge médio
17h 40min
PRs com merge (30d)
90

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de cameri/nostream

Todas as issues de cameri/nostream

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.