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

Add option to avoid printing DOM to log on failures #1260

Closed
IanVS opened this issue Sep 15, 2023 · 2 comments
Closed

Add option to avoid printing DOM to log on failures #1260

IanVS opened this issue Sep 15, 2023 · 2 comments

Comments

@IanVS
Copy link
Contributor

IanVS commented Sep 15, 2023

Describe the feature you'd like:

I am using this tool within Storybook, which means that it's not important for me to have a dump of the DOM output to the console every time a test fails, I can see the HTML as rendered in the page. And by having a long, long dump in the logs, it makes the test results when I run in CI more difficult to skim and find the actual error messages.

Suggested implementation:

Perhaps an option could be added to the configuration, which defaults to the current behavior, but allows turning off the DOM dump?

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

@MatanBobi
Copy link
Member

Hi @IanVS, sorry it took us time to get to this.
You can override the getElementError in the config to remove that.
I believe something like this should work:

  getElementError(message, container) {
    const error = new Error(
      [
        message,
        `Ignored nodes: comments, ${config.defaultIgnore}\n`,
      ]
        .filter(Boolean)
        .join('\n\n'),
    )
    error.name = 'TestingLibraryElementError'
    return error
  }

@IanVS
Copy link
Contributor Author

IanVS commented Oct 30, 2023

Thanks for pointing me in the right direction!

@IanVS IanVS closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2023
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

2 participants