Closed elShailee closed 1 year ago
Thanks for the detailed issue! Currently this plugin doesn’t work in the browser. However, I would like to add support for this. I was planning on troubleshooting some other issues in this project this week, so I might as well look into this one.
That would be really amazing if you could. but in case not - is there another way that I could make the mermaid-to-svg parse?
and thanks for the blazing quick response!
The current implementation runs mermaid in Chrome using puppeteer. This can’t be stubbed.
It’s actually pretty easy to add browser support. What I’m having issues with, is testing it. The only tool for the task that comes to mind is Karma, but it seems to be a bit outdated. Do you have an idea for a good testing framework?
Also I have a hunch maybe @ChristianMurphy has some ideas?
This sounds closely related to https://github.com/remcohaszing/remark-mermaidjs/issues/3
My understanding is also that some fresh implementation would be needed to support the browser. But it should be fairly straight forward for browsers, and could potentially even be made to work at build time. (for an example, see vFile which serves up different implementations based off the environment it is being built/bundled for https://github.com/vfile/vfile/blob/5181b5d0be113a6cb698be123d1226aadcac720c/package.json#L35-L47)
What I’m having issues with, is testing it. The only tool for the task that comes to mind is Karma, but it seems to be a bit outdated. Do you have an idea for a good testing framework?
Even if it isn't used at runtime, Puppeteer could still be used at testing time, and has integrations with Jest https://jestjs.io/docs/puppeteer
Or, @playwright/test
could be used as an alternative https://playwright.dev/docs/writing-tests
Another possibility is https://japa.dev/docs, which competes with Jest. But solves some key pain points for unified adopters who have tried Jest like: ESM support and C8 support.
Hello Team!
I encounter the same issue here, we want to add mermaid on remark for our react application ( we are using React-Markdown ).
If you need hands about testing don't hesitate!
Did you think about using Jest + Cypress ?
The problem with tools like Playwright and Puppeteer is that they’re tools that focus on automating the browser, not running tests inside the browser. This means the tests need to spin up a server, this server needs to bundle the JavaScript that runs the code to test, then the test framework can only access that page and make assertions about it. I was hoping for a more integrated solution.
Anyway, I appreciate the feedback. I’ll probably go with Playwright and esbuild serve.
I expect (but don’t promise) to fix and release this tomorrow.
I think this is solved by #9. The test setup has become quite unique though. I would appreciate a review, but I’ll release it this week regardless.
thank you! I think I'm kinda underqualified, but I tried my best as far as reviews go, for what it's worth...
Same here 😞
Hey Thanks for the amazing support! I notice you merged the browser support, but did not advance the package version, Which means (to the best of my understanding) that the new changes are not yet available via npm/yarn. is that intentional?
I was just about to release when you posted that. Browser support is now available as of version 3.1.0 :tada:
Hey, I am trying to use this module to display MD files that uses the mermaid syntax in a React app using ReactMarkdown, but facing difficulties -
Basically - as soon as I import the module my app won't run and fail to compile with this error message -
The app run great without the module import, including the use of ReactMarkdown, which is pretty much copy of their documentation.
This is the code I am trying to use it in - (note that even if I don't use the remarkMermaid object in the ReactMarkdown component the app won't compile)
adding my package.json content - in case it's relevant:
I am running the app locally with
yarn start
on a Windows 10 machine, with Google Chrome Thanks in advance for any help!