Skip to content

Feature: Support native ESM #36

@rschristian

Description

@rschristian
  • preact-testing-library version: 2.0.1
  • preact version: 10.5.13
  • node version: 14.16.0
  • npm (or yarn) version: yarn 1.22.10

Relevant code or config

import { render, screen } from '@testing-library/preact';

What you did:

Tried to import from @testing-library/preact'

What happened:

SyntaxError: The requested module '@testing-library/preact' does not provide an export named 'render'

      at jasmine2 (node_modules/jest-jasmine2/build/index.js:228:5)

Problem description:

Currently @testing-library/preact does not offer ESM output, which makes it unsuitable for testing in a native ESM environment. This will begin to be a problem especially now that Node 10 is EOL ("type": "module" was first valid in v12.0.0, the now oldest support version of Node).

@testing-library/react does however support ESM, so preact here is behind. Edit: Apparently not. Apparently Jest doesn't even follow the widely used practice of the module key: jestjs/jest#2702 (comment)

Suggested solution:

Offer ESM output. Will just take an alteration of the build script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions