Skip to content

ByDisplayValue warning message is quite misleading #442

Closed
@xgbuils

Description

@xgbuils
  • DOM Testing Library version: 6.12.0
  • node version: 10.11.0
  • npm (or yarn) version: 6.4.1

Relevant code:

import React from 'react';
import { render } from '@testing-library/react';
import { getByDisplayValue } from '@testing-library/dom';

describe('test', () => {
 test('test', () => {
   const { getByDisplayValue } = render(
     <select value="2" onChange={() => {}}>
       <option value="1">one</option>
       <option value="2">two</option>
     </select>
   );

   getByDisplayValue("2");
 });
});

What happened:

After executing this test, the warning message is "Unable to find an element with the value: 2."

Reproduction:

https://github.com/xgbuils/select-issue-rtl

Problem description:

As suggested @eps1lon in this issue, the warning message is quite misleading.

Suggested solution:

Show the message: "with the display value:"
Instead of: "with the value:"

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