Skip to content

Return type of unmount function #856

Closed
@sanchit121

Description

@sanchit121
  • @testing-library/react version: 11.2.2
  • Testing Framework and version: Jest 26.6.3
  • DOM Environment: jsdom

Relevant code or config:

export type RenderResult<Q extends Queries = typeof queries> = {
  container: Element
  baseElement: Element
  debug: (
    baseElement?:
      | Element
      | DocumentFragment
      | Array<Element | DocumentFragment>,
    maxLength?: number,
    options?: prettyFormat.OptionsReceived,
  ) => void
  rerender: (ui: React.ReactElement) => void
  unmount: () => boolean
  asFragment: () => DocumentFragment
} & {[P in keyof Q]: BoundFunction<Q[P]>}

What you did:

Trying to use unmount()

Problem description:

wrapper.unmount() returns undefined, whereas the type shows it returns boolean
...\node_modules@testing-library\react\types\index.d.ts

Suggested solution:

We can update the type definition file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions