mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-03 15:46:43 +02:00
test: Add visual testing for examples
This commit is contained in:
7
cypress/integration/rendering/examples.spec.ts
Normal file
7
cypress/integration/rendering/examples.spec.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { urlSnapshotTest } from '../../helpers/util.js';
|
||||||
|
|
||||||
|
describe.skip('Examples', () => {
|
||||||
|
it('should render all examples', () => {
|
||||||
|
urlSnapshotTest('http://localhost:9000/examples.html');
|
||||||
|
});
|
||||||
|
});
|
36
cypress/platform/examples.html
Normal file
36
cypress/platform/examples.html
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Examples</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from './mermaid.esm.mjs';
|
||||||
|
import { diagramData } from './mermaid-examples.esm.mjs';
|
||||||
|
for (const d of diagramData) {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
const h1 = document.createElement('h1');
|
||||||
|
h1.appendChild(document.createTextNode(d.name));
|
||||||
|
div.appendChild(h1);
|
||||||
|
div.appendChild(document.createTextNode(d.description));
|
||||||
|
for (const example of d.examples) {
|
||||||
|
const pre = document.createElement('pre');
|
||||||
|
pre.classList.add('mermaid');
|
||||||
|
pre.textContent = example.code;
|
||||||
|
div.appendChild(pre);
|
||||||
|
}
|
||||||
|
document.body.appendChild(div);
|
||||||
|
}
|
||||||
|
mermaid.initialize({
|
||||||
|
startOnLoad: false,
|
||||||
|
logLevel: 0,
|
||||||
|
});
|
||||||
|
await mermaid.run();
|
||||||
|
if (window.Cypress) {
|
||||||
|
window.rendered = true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user