Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for configure getElementError #52

Open
k03mad opened this issue Mar 4, 2024 · 0 comments
Open

Support for configure getElementError #52

k03mad opened this issue Mar 4, 2024 · 0 comments

Comments

@k03mad
Copy link

k03mad commented Mar 4, 2024

Hello 👋

If the testing-library is unable to find an element using getByRole or any other method, a lengthy stacktrace is generated when the test fails.

I attempted to configure the getElementError for a custom message as per the documentation:
https://testing-library.com/docs/dom-testing-library/api-configuration/#getelementerror

  // I am trying this in the tests of this library to ensure the issue is not related to our project
  // webdriverio-testing-library/test/async/configure.e2e.ts
  it('getElementError', async () => {
    configure({
      getElementError: (message, container) => {
        const customMessage = 'my custom message';
        return new Error(customMessage)
      },
    })

    const {getByRole} = setupBrowser(browser)

    await getByRole('button', {name: 'no such name'});
  })

However, I am not seeing 'my custom message' displayed when the test fails with an element not found error.
Am I doing something incorrectly, or this option is not supported yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant