From a1e64c21020d36c474d27ab76abb441106387f34 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sun, 7 May 2023 18:05:43 +0100 Subject: [PATCH] test: fix classDiagramGrammer unit test The classDiagramGrammer.spec.ts unit test had some bad filepath manipulation that fails on UNIX platforms. Instead, we can use the recommended method from the Node.JS documentation, see https://nodejs.org/api/esm.html#importmetaurl. Fixes: 221640aa258c9e8f97e8113a15a52097cb2d1cf8 --- .../mermaid/src/diagrams/class/classDiagramGrammar.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/classDiagramGrammar.spec.ts b/packages/mermaid/src/diagrams/class/classDiagramGrammar.spec.ts index eae09603f8..0d6fe200cb 100644 --- a/packages/mermaid/src/diagrams/class/classDiagramGrammar.spec.ts +++ b/packages/mermaid/src/diagrams/class/classDiagramGrammar.spec.ts @@ -1,10 +1,10 @@ import { readFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; // @ts-ignore - no types import { LALRGenerator } from 'jison'; -import path from 'path'; const getAbsolutePath = (relativePath: string) => { - return new URL(path.join(__dirname, relativePath)).pathname; + return fileURLToPath(new URL(relativePath, import.meta.url)); }; describe('class diagram grammar', function () {