mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 04:49:44 +02:00
Added e2e tests and snapshot files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* eslint-env jest */
|
||||
import { Base64 } from 'js-base64'
|
||||
|
||||
const mermaidUrl = (graphStr, options) => {
|
||||
export const mermaidUrl = (graphStr, options) => {
|
||||
const obj = {
|
||||
code: graphStr,
|
||||
mermaid: options
|
||||
@@ -10,4 +11,16 @@ const mermaidUrl = (graphStr, options) => {
|
||||
return 'http://localhost:9000/e2e.html?graph=' + Base64.encodeURI(objStr)
|
||||
}
|
||||
|
||||
export default mermaidUrl
|
||||
export const imgSnapshotTest = async (page, graphStr, options) => {
|
||||
return new Promise(async resolve => {
|
||||
const url = mermaidUrl(graphStr, options)
|
||||
|
||||
await page.goto(url)
|
||||
|
||||
const image = await page.screenshot()
|
||||
|
||||
expect(image).toMatchImageSnapshot()
|
||||
resolve()
|
||||
})
|
||||
// page.close()
|
||||
}
|
||||
|
Reference in New Issue
Block a user