Skip to content

"moduleResolution": "Node16" default/named export bug #1062

Open
@jroru

Description

@jroru

Reproduction example

Note: unable to provide a codesandbox link due to the inability to control the version of TypeScript used by the IDE

Prerequisites

  1. [email protected]
  2. @testing-library/[email protected]
  3. package.json type: module
  4. tsconfig moduleResolution set to Node16
// 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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds specificationThe desired behavior is not defined yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions