mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-14 22:09:29 +02:00
test(refactor): Use real-ish rendering instead of heavy mocking in unit tests
* 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
This commit is contained in:
@@ -16,7 +16,6 @@ export default defineConfig({
|
||||
environment: 'jsdom',
|
||||
globals: true,
|
||||
// TODO: should we move this to a mermaid-core package?
|
||||
setupFiles: ['packages/mermaid/src/tests/setup.ts'],
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'json', 'html', 'lcov'],
|
||||
|
Reference in New Issue
Block a user