dwmkerr / chatgpt-diagrams-extension

A Chrome browser extension that renders diagrams in the ChatGPT website inline.
MIT License
13 stars 3 forks source link

bug: mermaid error output is not correctly captured in tests #20

Closed dwmkerr closed 1 year ago

dwmkerr commented 1 year ago

See currently ignored test shows mermaidjs error content in the diagram container when rendering fails.

Root of the issue appears to be that the mermaid error content is not correctly added to our DOM when we are in the test environment. In the browser it seems to render fine (I think it even may have rendered correctly one time in the debugger).

Most likely the Mermaid.js library is using the global document object for something, compared to what is in JSDOM, and there is a clash. Enable the test to debug and fix. This will allow us to verify that Mermaid.js shows proper error output. At the moment I have to verify this manually.

Note that interestingly Mermaid success output renders in JSDOM just fine.

Also note that if you do not pass the container div to mermaidjs (so that it renders the error content in the global document object) we also see the expected error output.