testing-library / testing-library/user-event
"moduleResolution": "Node16" default/named export bug
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction example
Note: unable to provide a codesandbox link due to the inability to control the version of TypeScript used by the IDE
Prerequisites
typescript@4.8.3@testing-library/user-event@14.4.3- package.json
type: module - tsconfig
moduleResolutionset toNode16
// tsconfig
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node16"
}
}
Expected behavior
userEvent should be the default export of the module
import userEvent from "@testing-library/user-event";
userEvent.click(...);
Actual behavior
userEvent is exported as a named export called default
import userEvent from "@testing-library/user-event";
userEvent.default.click(...);
User-event version
14.4.3
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
This may be invalid for Node 16's ESM spec.
I suspect changing it to the following will resolve the issue:
import {userEvent} from './setup';
export default userEvent;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/index.ts at the linked export and compare it with the referenced ./setup module. Reproduce the default-versus-named export behavior using TypeScript 4.8.3, Node16 module resolution, and @testing-library/user-event 14.4.3; done means the documented default import exposes click directly without .default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100