Skip to content

Working with preact/compat #24

Closed
Closed
@whilelucky

Description

@whilelucky
  • preact-testing-library version: 1.0.2
  • preact version: 10.4.4
  • node version: 12.16.3
  • npm (or yarn) version: yarn 1.22.4

Relevant code or config

// jest.config.js
moduleNameMapper: {
    '^react$': 'preact/compat',
    '^react-dom/test-utils$': 'preact/test-utils',
    '^react-dom$': 'preact/compat',
    '^@testing-library/react$': '@testing-library/preact',

What you did:
Tried to alias @testing-library/react to @testing-library/preact because we're aliasing react and react-dom to preact/compat.

What happened:
Fails with an error that it cannot find waitFor, but I also suspect there may be other differences in the api's of both the libraries.

Reproduction repository:

Problem description:
We'd like our jest tests to run against preact and not react as long as we are using the preact/compat alias so that we know our tests(and hence implementations) work in preact.

Suggested solution:
Firstly, update the @testing-library/dom package to the latest version, and secondly, match any other mismatches in the library apis.

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