Giter Site home page Giter Site logo

Comments (3)

soullivaneuh avatar soullivaneuh commented on May 27, 2024

I tried the same thing and got the similar problem.

Here is the related test:

import {
  expect,
  test,
} from 'bun:test'
import {
  render,
  screen,
} from '@testing-library/react'
import * as extensions from '@testing-library/jest-dom/matchers'
import App from './App'

expect.extend(extensions)

test('renders', async () => {
  render(<App  />);

  expect(screen.getByText('Click on the Vite and React logos to learn more')).toBeInTheDocument();
})

Running bun tsc --noEmit gave me:

src/App.test.tsx:12:15 - error TS2345: Argument of type 'TestingLibraryMatchers<any, void> & Record<string, any>' is not assignable to parameter of type 'ExpectExtendMatchers<{ [x: string]: ...; toBeInTheDOM: unknown; toBeInTheDocument: unknown; toBeVisible: unknown; toBeEmpty: unknown; toBeEmptyDOMElement: unknown; toBeDisabled: unknown; toBeEnabled: unknown; toBeInvalid: unknown; toBeRequired: unknown; toBeValid: unknown; toContainElement: unknown; ... 15 more ...;...'.
  Types of property 'toBeInTheDOM' are incompatible.
    Type '(container?: HTMLElement | SVGElement | undefined) => void' is not assignable to type 'CustomMatcher<unknown, any[]>'.
      Types of parameters 'container' and 'expected' are incompatible.
        Type 'unknown' is not assignable to type 'HTMLElement | SVGElement | undefined'.

12 expect.extend(extensions)
                 ~~~~~~~~~~

src/App.test.tsx:17:79 - error TS2339: Property 'toBeInTheDocument' does not exist on type 'Matchers<HTMLElement>'.

17   expect(screen.getByText('Click on the Vite and React logos to learn more')).toBeInTheDocument();
                                                                                 ~~~~~~~~~~~~~~~~~

However, the test is running as expected. Only the typing is the issue here.

from jest-dom.

jakeboone02 avatar jakeboone02 commented on May 27, 2024

@soullivaneuh I just submitted #566 to address this issue.

from jest-dom.

github-actions avatar github-actions commented on May 27, 2024

🎉 This issue has been resolved in version 6.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

from jest-dom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.