* Creates a utility method `jsdomIt` that overrides `it` from `vitest` and fakes a browser environment by :
* Creating a DOM with `jsdom` (and `canvas`)
* Adding (for the duration of the test) that DOM's `window` and `document` on `global`
* Monkey-patching DOM methods that require a rendering engine (`Element.getBBox` & `Element.getComputedLength`)
* Removes all d3 mocking since it can now work normally in `jsdomIt` tests
* Re-writes existing rendering tests to :
* Use `jsdomIt`
* Get rid of most of the involved mocking
* Run `expect` calls on the generated SVG instead
Inspired by d3's own test code mocking : https://github.com/d3/d3-selection/blob/v3.0.0/test/jsdom.js
The `node16` module resolution requires imports to use the `.js` file
extension in type definitions.
`@rollup/plugin-typescript` is needed to make this work with the Vite
setup used by Mermaid.
The module option for Mermaid internally is set to `nodenext`. This is
needed to support `.json` imports. Note that setting `module` to
`node16` or `nodenext` implies a matching `moduleResolution` value.