iamkun / iamkun/dayjs

Issue running dayjs in Jest test

Open
#1,669 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I use rescript which compiles to js. It compiles imports like this:
import * as Dayjs from "dayjs";

As a result, my component using dayjs is untestable. When it runs in jest it errors: with
```
TypeError: t is not a function
``

**Expected behavior**
Be able to compile rescript and run tests easy!

**Information**
- Day.js Version ^1.10.7
- OS: Windows
- Browser: N/A node unit test
- Time zone: EST

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure in the Jest test with the ReScript-generated import `import * as Dayjs from "dayjs"`, then inspect the reported `TypeError: t is not a function` in the Node test environment. Compare the generated import behavior with Day.js ^1.10.7; done means the compiled ReScript component runs successfully under Jest.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.