hapijs / hapijs/joi-date

V3 - dayjs usage of `customParseFormat` is conflicting with our own usage of extension `customParseFormat`

Open
#50 1 comment 0 reactions 0 assignees View on GitHub
support
Dominant language
TypeScript
Stars
80
Forks
22
PR merge metrics
No merged PRs in 30d

Description

### Runtime

node.js

### Runtime version

v24.18.0

### Module version

v3

### Used with

hapi application

### Any other relevant information

_No response_

### How can we help?

I am trying to upgrade to v3 for our main app available in [@1024pix/pix/api repository](https://github.com/1024pix/pix).

Unfortunately, our unit tests are failing (you can run them with `npm run test:api:unit`).
When looking closer to why, I found out that we are extending `dayjs` in the file `src/shared/infrastructure/utils/date-utils.js` with `customParseFormat` and overriding `parseTwoDigitYear`.

When running tests that is both using `@hapi/day` and our day utils, our custom format is not taken into account and thus our test are failing.

You can run subset of tests to show the issue with
```
npm run test:api:path -- tests/certification/configuration/unit/application/certification-version-route_test.js tests/shared/unit/infrastructure/utils/date-utils_test.js
```

Any idea on how to fix this ?

Contributor guide

Open the contributing guide

Research direction

Run the listed npm test commands in the linked @1024pix/pix/api repository, then inspect src/shared/infrastructure/utils/date-utils.js and the two named test files. Trace how @hapi/day and the customParseFormat extension are loaded together; done means the focused tests pass while the custom parseTwoDigitYear behavior remains effective.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.