Skip to content

Commit f8e1667

Browse files
authored
Merge pull request #73 from craig-jennings/main
feat: update svgo to v4
2 parents 9b88f2d + 658f0bf commit f8e1667

23 files changed

+60
-44
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ const config = {
4646
plugins: [
4747
{
4848
name: 'preset-default',
49-
// by default svgo removes the viewBox which prevents svg icons from scaling
50-
// not a good idea! https://github.com/svg/svgo/pull/1461
51-
params: { overrides: { removeViewBox: false } },
5249
},
5350
{ name: 'removeAttrs', params: { attrs: '(fill|stroke)' } },
5451
],

package-lock.json

Lines changed: 31 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@
9393
},
9494
"dependencies": {
9595
"@rollup/pluginutils": "5.1.4",
96-
"svgo": "^3.2.0"
96+
"svgo": "^4.0.0"
9797
}
9898
}

test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"svelte": "5.20.1",
2020
"svelte-check": "4.1.4",
2121
"svelte-preprocess": "^6.0.3",
22-
"svgo": "3.3.2",
22+
"svgo": "4.0.0",
2323
"vite": "6.0.11"
2424
}
2525
}

test-app/tests/test.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,75 @@ test('SVG as inline component', async ({ page }) => {
1212
await page.goto('/')
1313
const svg = page.locator('#inline-comp > svg')
1414
expect(await outerHtml(svg)).toMatchSnapshot('inline-comp.svg')
15+
await expect(svg).toHaveScreenshot()
1516
})
1617

1718
test('SVG as inline string', async ({ page }) => {
1819
await page.goto('/')
1920
const svg = page.locator('#inline-string > svg')
2021
expect(await outerHtml(svg)).toMatchSnapshot('inline-string.svg')
22+
await expect(svg).toHaveScreenshot()
2123
})
2224

23-
// FIXME: This test breaks when running in this test context (we get a data url)
24-
// but it works fine when you look at the page in a browse when running
25-
// the server
26-
test.skip('As URL in an image tag', async ({ page }) => {
25+
test('As URL in an image tag', async ({ page }) => {
2726
await page.goto('/')
2827
const img = page.locator('#image > img')
29-
expect((await img.getAttribute('src')).includes('sample-logo')).toEqual(true)
30-
expect(await img.getAttribute('alt')).toEqual('Sample logo')
28+
await expect(img).toHaveAttribute(
29+
'src',
30+
expect.stringContaining('sample-logo')
31+
)
32+
await expect(img).toHaveAttribute('alt', 'Sample logo')
33+
await expect(img).toHaveScreenshot()
3134
})
3235

3336
test('With component props', async ({ page }) => {
3437
await page.goto('/')
3538
const svg = page.locator('#with-props > svg')
36-
expect(await svg.getAttribute('width')).toEqual('200')
37-
expect(await svg.getAttribute('aria-hidden')).toEqual('false')
39+
await expect(svg).toHaveAttribute('width', '200')
40+
await expect(svg).toHaveAttribute('aria-hidden', 'false')
41+
await expect(svg).toHaveScreenshot()
3842
})
3943

4044
test('From another directory', async ({ page }) => {
4145
await page.goto('/')
4246
const svg = page.locator('#from-another-dir > svg')
4347
expect(await outerHtml(svg)).toMatchSnapshot('from-another-dir.svg')
48+
await expect(svg).toHaveScreenshot()
4449
})
4550

4651
test('As data URL', async ({ page }) => {
4752
await page.goto('/')
4853
const img = page.locator('#dataurl > img')
4954
expect(await img.getAttribute('src')).toMatchSnapshot('base64imageurl.txt')
55+
await expect(img).toHaveScreenshot()
5056
})
5157

5258
test('As data URL with explicit base64', async ({ page }) => {
5359
await page.goto('/dataurl')
5460
const img = page.locator('#b64e > img')
5561
expect(await img.getAttribute('src')).toMatchSnapshot('base64explicit.txt')
62+
await expect(img).toHaveScreenshot()
5663
})
5764

5865
test('As data URL with explicit enc', async ({ page }) => {
5966
await page.goto('/dataurl')
6067
const img = page.locator('#enc > img')
6168
expect(await img.getAttribute('src')).toMatchSnapshot('enc.txt')
69+
await expect(img).toHaveScreenshot()
6270
})
6371

6472
test('As data URL with explicit unenc', async ({ page }) => {
6573
await page.goto('/dataurl')
6674
const img = page.locator('#unenc > img')
6775
expect(await img.getAttribute('src')).toMatchSnapshot('unenc.txt')
76+
await expect(img).toHaveScreenshot()
6877
})
6978

7079
test('Transform hook', async ({ page }) => {
7180
await page.goto('/hook')
7281
const svg = page.locator('svg > title')
73-
const title = await svg.textContent()
7482

75-
expect(title).toEqual('Official SVG Logo')
83+
await expect(svg).toHaveText('Official SVG Logo')
7684
})
7785

7886
test('Optimized URL import', async ({ page }) => {
19.4 KB
Loading
1.69 KB
Loading
1.58 KB
Loading
1.58 KB
Loading
1.6 KB
Loading

0 commit comments

Comments
 (0)