mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-14 22:09:29 +02:00

* 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