testing-library / testing-library/user-event

moduleResolution: "nodenext" on tsconfig cannot resolve userEvent

Open
#1,120 6 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs assessment
Dominant language
TypeScript
Stars
2.3k
Forks
258
PR merge metrics
No merged PRs in 30d

Description

Reproduction example

https://codesandbox.io/p/github/ricardo-passthrough/userevent-nodenext-repro/main?layout=%257B%2522activeFilepath%2522%253A%2522%252FREADME.md%2522%252C%2522openFiles%2522%253A%255B%2522%252FREADME.md%2522%255D%252C%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522gitSidebarPanel%2522%253A%2522COMMIT%2522%252C%2522fullScreenDevtools%2522%253Afalse%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522vertical%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522DEVTOOLS_PANELS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522panelType%2522%253A%2522TABS%2522%252C%2522id%2522%253A%2522clgr11t6d00093b6id8cmkdak%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clgr11t6d00093b6id8cmkdak%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clgr11t6d00083b6im5ecqgqt%2522%252C%2522type%2522%253A%2522PROJECT_SETUP%2522%257D%255D%252C%2522id%2522%253A%2522clgr11t6d00093b6id8cmkdak%2522%252C%2522activeTabId%2522%253A%2522clgr11t6d00083b6im5ecqgqt%2522%257D%257D%252C%2522showSidebar%2522%253Atrue%252C%2522showDevtools%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%252C%2522editorPanelSize%2522%253A50%252C%2522devtoolsPanelSize%2522%253A35%257D

Prerequisites

Setup a tsconfig.json with moduleResolution "nodenext".

Expected behavior

the following code snippet should build:

import userEvent from '@testing-library/user-event';

test('user event', () => {
    userEvent.setup();
})
Actual behavior

Line 4 fails with

Property 'setup' does not exist on type 'typeof import("${HOME}/Projects/repro/node_modules/@testing-library/user-event/dist/types/index")'.
User-event version

14.4.3

Environment

No response

Additional context

When running jest, the issue only happens if I set the preset to ts-jest. When using babel, the test runs fine--you can check on the repo https://github.com/ricardo-passthrough/userevent-nodenext-repro/tree/babel-test.
Clicking through the import in VSCode sends me to node_modules/@testing-library/user-event/dist/types/index.d.ts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction's tsconfig.json and the package entry points referenced by the import, especially dist/types/index.d.ts. Run the provided TypeScript/Jest reproduction with moduleResolution set to "nodenext" and compare it with the Babel setup. Done means the example builds and userEvent.setup() is correctly available under the affected configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.