Skip to content

Commit

Permalink
test: fix svgdom setup for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Voellmy Raphael authored and Voellmy Raphael committed May 16, 2020
1 parent 2f34373 commit cec30e0
Show file tree
Hide file tree
Showing 3 changed files with 1,795 additions and 1,090 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"@types/jest": "^25.1.0",
"@types/jest": "^25.2.2",
"@types/node": "^14.0.0",
"colors": "^1.3.2",
"commitizen": "^4.0.3",
"coveralls": "^3.0.2",
"cross-env": "^7.0.0",
"cz-conventional-changelog": "^3.0.2",
"husky": "^4.0.2",
"jest": "^25.3.0",
"jest": "^26.0.1",
"jest-config": "^25.3.0",
"jest-each": "^26.0.0",
"lint-staged": "^10.0.3",
Expand Down Expand Up @@ -130,8 +130,8 @@
"typescript": "^3.7.2"
},
"dependencies": {
"@svgdotjs/svg.js": "^3.0.13",
"@svgdotjs/svg.js": "^3.0.16",
"roughjs": "^4.0.1",
"svgdom": "^0.1.1"
"svgdom": "^0.1.8"
}
}
5 changes: 4 additions & 1 deletion test/testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { join } from 'path'
export const svgOutputDir = './test-renders'

export function setUpSvgDom(): Document {
const window = require('svgdom')
const svgdom = require('svgdom')
svgdom
// your font directory
.setFontDir('./fonts')
// map the font-family to the file
Expand All @@ -14,6 +15,8 @@ export function setUpSvgDom(): Document {
// when the font is used the first time
.preloadFonts()

const window = svgdom.createSVGWindow()

const { registerWindow } = require('@svgdotjs/svg.js')
registerWindow(window, window.document)

Expand Down
Loading

0 comments on commit cec30e0

Please sign in to comment.